The Simplest Vertical Slice Architecture With .NET 8

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

Are you tired of organizing your project across layers? Vertical Slice Architecture is a compelling alternative to traditional layered architectures. VSA flips the script on how we structure code. Instead of horizontal layers (Presentation, Application, Domain), VSA organizes code by feature. Each feature encompasses everything it needs, from API endpoints to data access. In this video, we will explore how you can structure vertical slices in VSA.

Vertical Slice Architecture

Vertical Slice Architecture: Structuring Vertical Slices

Check out my courses:

Read my Blog here:

Join my weekly .NET newsletter:

Chapters
0:00 Understanding Vertical Slice Architecture
4:53 Implementing a simple Vertical Slice
8:53 Extending the Vertical Slice with validation
11:15 Adding more Vertical Slices to the example
Рекомендации по теме
Комментарии
Автор

Something else that nobody has mentioned, it’s super easy to
Wrap the entire slice in a feature flag. Which opens door for a ton of flexible development options.

cas
Автор

Hi Milan, you produce so many interesting videos, that it takes all my day to view all of them !

olivier
Автор

Great video! I hope you consider creating a full video on sharing code between slices. Code duplication can be a challenging, it would be nice to see different strategies for reducing duplication.

nikolaknezevic
Автор

Great stuff, Milan and also much congratz on getting MVP :)

As for the video, I, personally, prefer using Clean + Vertical at the same time for non-crud apps, separating slices (folders basically) between projects. I.e "Products" folder in all projects. With enough dedication and discipline you can get best of both worlds.

Great example anyway and love your approach with IEndpoint reflection stuff :)

Fikusiklol
Автор

Great video!

A nice video you could do:

- best practices C#12
- Best practices .NET 8 (top X best practices in general)…
- Doing some talks on clean code…

jawadsrour
Автор

Nice, finally I can see a good and complete VSA example!
Just one question, how would you suggest using this for gRPC, given that you need to handle proto files?

ruekkart
Автор

Could you do a video on Owned Properties vs EF's new Complex Types and the nuances between them?

drhdev
Автор

Thank you for your videos. I like the vertical slice architecture. What do you think about organising vertical slice architecture with multiple "mains" like a WebAPI project and a console project. The core should be the same on both. How do you structure such a project? My answer is to make the core vertical slice architecture and the multiple main project are implementend like the hexagonal architecture which access the public interface of the core.

buri-kizilkaya
Автор

Could you make a video about the best practices with multithreading, async, etc?

MjwAllMusic
Автор

Hey Milan,
Thank you for sharing this resource to us. However, a have a doubt: I have an entity named "Item" in selling and stock context, and if I understood well this entity can does move with cross-cutting. In this case, will are through of domain events? For example, I sold a guitar and I need to update my stock, can I create a domain event to update it?

alessandrohudson
Автор

Interesting approach - but is this really feasible when things get more complicated? Would you organize a more complex project this way? I organize my vertical slices in a hierarchical folder structure - this scaled well for me so far.

IAmFeOx
Автор

great video! one question, if you have another vSlice and you access the same datamodel, do you share those objects? if so, how do you manage dependencies? if not, how do you deal with rich domain models?

ChristophLoacker
Автор

Hi Milan, thanks for the great video!

I have a question though. Is there a purpose for putting the different components inside a static class (effectively the REPR pattern), as opposed to putting it in a namespace? And then reference it in the same way if you like, i.e. CreateProduct.Request, etc.. ?

ajdinhusic
Автор

Thank you Milan for the easiest explanation... Can i use controller instead of map endpoint?

MohamedibinAhmed
Автор

In the source code, I see that AppDbContext is under Products. So does this mean there will be a DbContext instance for each vertical slice? Shouldn't AppDbContext be moved out of Products?

sirg
Автор

I'm really interested in how to structure entities and their configurations in vertical slice. Should I place these two in same folder as my request command handler and response classes? Or maybe place them in different folders?

arteqppp
Автор

Great Video like always :D You mentioned to map the validation result to a ProblemDetails and currently I am trying to that with the Results pattern. So map the Errors in a Result to a ProblemDetails, but I am failing misserably. Could you make a video on that, where you show, how to map the Errors of a Result to ProblemDetails within minimal API. I know it's fairly easy to that with MVC controllers, but MinimalAPI gives me a headache.

My use case is that I am validating business logic and want to return custom errors. So for example CreateProducts validates if the product already exists and if it exists return Result.Fail("custom message with error details). And I want to map the Error to a problem details within minimalAPI. The controller would return something like this:

return response.IsSucess ? Results.Ok() :

simonklein
Автор

I do have a hard time understanding what 'use case' implies here! Is 'use case' in the sense of requirements, as it exists in RUP? If yes, that would end up being a class diagram. However, it seems the meaning of 'use case' is different in the context of CA

mehdi-vlnn
Автор

Hi Milan. This is great, but it can be even simpler. You don't need the repository layer (just use Dapper and DbUp).

Bennevisie
Автор

I like the idea of vertical slice architecture. I am just worried how it would work in a large repo.

Ziirf