How To Move From Clean Architecture to Vertical Slice Architecture

preview_player
Показать описание

Layered architectures are the foundation of many software systems. However, layered architectures organize the system around technical layers. And the cohesion between layers is low. What if you wanted to organize the system around features instead? Minimize coupling between unrelated features and maximize coupling in a single feature. Today, I want to talk about Vertical Slice Architecture, which does precisely that. We're going to take a Clean Architecture project and refactor it towards Vertical Slice Architecture.

Vertical Slice Architecture

Join my weekly .NET newsletter:

Read my Blog here:

Chapters
0:00 Starting from the Clean Architecture
1:49 Introducing a Feature folder
5:12 Adding more Vertical Slices
10:30 Events can be Vertical Slices also
12:19 Discussion about abstractions
Рекомендации по теме
Комментарии
Автор

Thanks Milan. This really clears a lot of doubt clouds.

Piyush-mgzq
Автор

Nice example, Milan.
But Im personally leaning towards a mix of Clean / Vertical, where you still have slices, just across projects.
To separate concerns and make it testable.
Like if you had Orders folder with its features in Domain / Application / Infrastructure projects.

Fikusiklol
Автор

Nice explanation Milan. So, are we going to end up with a single project in VSA?

gakshay
Автор

Great explanation, thanks!
Do you find that your testing becomes more challenging when you remove the abstractions (needed in Clean Architecture) and use the concrete types directly? Does this require the use of integration tests more than unit tests?

joehernandez
Автор

Hey Milan, great video. Best c# content on internet. Just a question, in your opinion, what are the points one should consider when choosing vertical slices over clean arch? Do you still use both, or do you have a preference nowadays. Thank you. Keep it up.

fernandohcortez
Автор

How do you implement reusability in VSA? I mean lets say I call the dbcontext to get some object "SampleObject" in many of the Handlers, i realise i am using the same logic to retrive the object many times so decide to make it a method. Normally i would use Repository pattern for this, what do you think?
Also, what if is is not a database operation but instead some business logic that i see myself rewriting in many Handlers. Where would i put this reusable method?

DaminGamerMC
Автор

I really love this approach. Moving through different layers sometimes it's a bit painful. Quick question. I moved my features to my API project but the validators used to live in the Application project. Is it allowed to move the mapper definitions to one slice, the entity feature?

ayanesuarezromero
Автор

The Clean Architecture structure you start with is a bad one. The clean arch directory structure should not be applied at the top level but on a module/context/feature (you name it) level. You violate the cohesion rule. Why do you force me to move around other features' directories when I'm only interested in one? I should enter a feature directory once, focus only on this context and forget about others.

marcinb
Автор

Does Vertical Slicing refer to the same concept as Modular Monolith?

BlazorPlate
Автор

Milan, a bit off topic, but what do you think of the increased fee on Upwork that took place this year? 5% towards the 10% for $10k+?

lettuceturnipthebeets
Автор

what happen with application project in this case?

JANDRESCR
Автор

Thanks for the video !
I hope to see also the opposite, from vertical slices to clean ?

houdaifabouamine
Автор

this is so wrong, this is not VSA ... and what about your namespaces ?!!!!

KsiProgramming
Автор

What is this "Maybe" class you have in your controllers? I'm interested in how these methods look like.

HeyWhoTheFuckAreYou