Restructuring to a Vertical Slice Architecture
Video Statistics and Information
Channel: CodeOpinion
Views: 8,558
Rating: undefined out of 5
Keywords: vertical slice architecture, software architecture, software design, cqrs, event sourcing, design patterns, software architect, .net, .net core, asp.net, asp.net core, soa, microservices, event driven architecture, service bus, mass transit, nservicebus, messaging patterns, service oriented architecture, microservice architecture, domain-driven design, enterprise service bus, clean architecture, feature slices, vertical feature slice, Vertical slice archetecture
Id: cVVMbuKmNes
Channel Id: undefined
Length: 17min 50sec (1070 seconds)
Published: Wed Jul 28 2021
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Tried out VSA earlier this year after using Onion and I never want to go back π
Love it. Having all aspects of a feature in one place, rather than scattered across multiple assemblies. Which then have their own tests at different levels scattered across multiple test assemblies. Would make it so much simpler to work on. Like you say, there is little point in grouping things by layer when it's features you work on rather than layers.
One thing that made be pause though is removing the abstraction of the repository level. Say you added some flag to your Order entity. Like a soft delete or something. You then want (almost) all queries to only return all orders that are not soft deleted. With a repository you would change the repository method and have all calls to it display the newly desired behaviour. You can also find all references to that method and easily see where it is used. What would you do with VSA? Manually comb through the code for every instance of fetching Orders and update each one? Or is there something more elegant that I'm missing?
This coin has 2 sides, as always.
From one side - yes, instead of creating all those interfaces and implementations for all a dependences for every action, distributed across several projects (or even nugets) this approach is much more readable and easily supported.
From other side, when logic in handlers becomes more complicated than CRUD ... he haven't shown the way he is doing the tests. And here can be the real problem with this approach.
The problem with videos/articles like these is that they assume one size fits all. There's rarely only one right way to do things, architecture is highly dependent on project requirements.
Looks nice for small things when we can separate use cases.
But when it comes to larger systems and complicated business logic I am afraid that it may quickly become a nightmare.
It's pedantic, but also accurate, you should have used "Restructuring" instead of "Refactoring" for your title.
Other than that, interesting stuff!
Back in the day we would have a
GetMyOrders.aspx
for the UI and aGetMyOrders.aspx.cs
for the code behind it. I guess we have come full circle.By the way, the thing not related to the approach itself, but it makes it not so clean. In many cases writing queries directly to the database is not good at all. It's better to abstract the calls with some repositories with business-related calls and hide db connect from feature developer.
Why? Because if all the db queries will be in one repository (even better in separate nuget) it can be controlled/reviewed by the team, which will ensure, that all the queries are covered by right indexes. Also this team can do the speed tests of this repo and refactor/limit code, make some caching, db separations ... etc. And all this not touching other team components. For high-load projects it can be really critical. If all db calls are spread between 1000 features in code files - it will be fully impossible.
What I canβt get to work properly is to have the razor files on a library when using MVC. Thatβs my main issue with VSA currently.