Slice It Vertical or Horizontal?
Today’s Situation
After our Clean Architecture chat, Onii-chan said “there’s another way too.” “Vertical Slice Architecture”… slicing vertically, what does that even mean?
Characters
- Netsuki: Virtual fox girl. Super excited about new design patterns
- Miko: Cat maid. Vertical or horizontal, doesn’t matter for cooking, nya
Hey Miko, remember when we talked about Clean Architecture?
…Separating important stuff from the rest, nya.
You remembered! (≧∇≦)
…So what is it today, nya.
So like, Onii-chan told me there’s another way to do it!
…Another way.
It’s called Vertical Slice Architecture!
…More fancy English words, nya.
Layer Cake vs A Slice of Shortcake
Lemme explain with food!
…Go on, nya.
Clean Architecture is like a layer cake
…A cake with horizontal layers, nya.
Right right! Sponge, cream, fruit… stacked horizontally, y’know?
…Each layer has its role, nya.
Same with programs! You split it into “UI layer,” “logic layer,” “data layer”
…Division of labor, nya.
But Vertical Slice Architecture is like… a single slice of shortcake!
…A slice, nya?
One slice has strawberry, cream, AND sponge all in it, right?
You group everything needed for one “feature” by cutting vertically
What Happens When You Cut Horizontally
…But layer cake is tasty too, nya.
Totally! Neither is wrong, they’re just different
…Then what’s the difference, nya.
The problem is when you wanna change something
…
Say you wanna swap strawberries for blueberries
…Still talking about cake, nya?
With a layer cake, it affects ALL the layers. You gotta fix every layer that has strawberries
…That’s a pain, nya.
But with a single shortcake slice, you only change that one slice
…Doesn’t affect the other slices, nya.
Exactly! (≧∇≦)
Born from Pain in 2018
…Who came up with this, nya.
A guy named Jimmy Bogard! He introduced it in 2018
…
He’s the creator of AutoMapper and MediatR - tools that like, EVERY programmer uses
…A famous person, nya.
And he came up with this because he kept getting burned by layer-based development
…Getting burned.
To change one feature, you gotta modify stuff across multiple layers. Files scattered everywhere, super hard to track…
…The other day, you were complaining about your “refactoring festival,” nya.
Ugh… you remembered that (>_<)
…Same pain, nya.
Maybe that’s why Vertical Slice resonates with me…
Ever Heard of Vibe Coding?
Oh oh, there’s one more interesting thing!
…There’s more, nya.
Have you heard of “vibe coding”?
…Vibe? Like the feeling, nya?
Yep yep! A guy named Andrej Karpathy started using this term in 2025
…What does he do, nya.
He’s one of the founders of OpenAI and used to lead AI at Tesla!
…
So vibe coding is… telling AI “something like this” and having it write code for you
…That’s just being lazy, nya.
Whoa, that’s harsh…!
…If someone asks me to cook “something like this,” I wouldn’t know what to make, nya.
Hmm, but AI is different from humans - it can actually produce something decent from vague instructions
…”Decent,” nya.
…Yeah, just “decent”
How AI and Architecture Get Along
…So how does this relate to Vertical Slice, nya.
Actually, when developing with AI, layer-based architecture causes problems
…What kind, nya.
AI doesn’t have things like “jump to definition”
…I don’t understand, nya.
Well, when humans develop, if they wanna see inside a function, they just click and instantly jump there
…Convenient, nya.
But AI can’t do that “click and jump” thing. It has to guess the filename, open it, read it… one step at a time
…Takes time, nya.
Right! So when files are scattered everywhere, AI gets lost easily
…
But with Vertical Slice, everything for one feature is in one place, so…
…It won’t get lost, nya.
Exactly! (≧∇≦)
But It’s Not Perfect
…Then just use Vertical Slice for everything, nya.
You’d think so, right? But here’s the thing…
…
Vertical Slice has its own pitfalls
…What, nya.
What do you do with stuff that’s “used by multiple features”?
…Like dashi stock, nya.
Ooh, nice one Miko! (゚∀゚)
…Used for miso soup and simmered dishes. But making it fresh every time is a pain, nya.
Right right! And if you put too much common stuff in one place because “it’s convenient”…
…Everything ends up depending on it, nya.
Yep. You end up with a “second layer cake”
…Defeats the whole purpose, nya.
So sometimes it’s better to accept a little code duplication than force everything to be shared
”Wrong Abstraction Is Worse Than Duplication”
…Duplication is okay, nya?
In the Vertical Slice world, there’s this saying: “Wrong abstraction is worse than a little duplication”
…Abstraction.
Like when you see similar things and go “let’s combine these into one”
…
But sometimes things that “look similar” actually exist for different reasons
…Example, nya.
Hmm… mirin and cooking sake look similar but have different roles, right?
…Completely different, nya. Mirin adds sweetness and gloss, cooking sake removes odor and adds umami.
But what if someone combined them into “cooking liquid” because they’re both “liquids you add to food”?
…Useless, nya. Each one loses its purpose.
Exactly! So combining things just because they look similar causes problems later
…I see, nya.
Wrap-up
…So which one’s better, nya.
Both are valid! Just different use cases
…
But when coding with AI, I think Vertical Slice might work better
…Why, nya.
When everything for a feature is grouped together, AI can easily see “oh, I just need to look here”
…In cooking terms, it’s like laying out all ingredients for today’s dish in one spot, nya.
Exactly! Way easier than grabbing stuff from all over the fridge, right?
…Mise en place, nya.
M-mise en place? (゚∀゚)
…French culinary term, nya. Means “putting in place” - preparing and arranging all ingredients before cooking.
Whoa, Miko knows so much!
…Basic cooking knowledge, nya.
Then Vertical Slice is like “mise en place for code”~♪
…You don’t have to force the connection, nya.
Ehehe (〃´∪`〃)
Related Links: