In Vertical Slice Architecture, we also apply this principle to a feature.
The Single Responsibility Principle (SRP) in software development instructs developers to write code that has one and only one reason to change. The exact same principles apply when writing code, therefore Cohesion in software development is the drive to have related code grouped together. When writing Cohesion means that the writing is well structured with linked ideas that follow a logical pattern. Advantages of Vertical Slice ArchitectureĪfter implementing several projects using the Vertical Slice architecture I have been able to identify several advantages and have fine tuned some recurring patterns and practices that make development using this approach a pleasurable experience. Therefore removing, deleting or editing a feature can be done by working in one folder. Whenever a feature is added, removed, or changed the things that change should not be scattered across the entire code base. Melting Abstractions – There are no gates or barriers across layers – everything needed for the system to do something is included in the slice itself where possible.Īxis Of Change – a core tenet of vertical slicing is a belief that things that change together should be near each other. Splitting off features/capabilities for things like scaling out is much less difficult. Use-case Driven – System are developed based on a slice and structured around Features and Capabilities. Principles of Vertical Slice Architecture Maximize cohesion along axes of change and minimize coupling between them.Things that change together, belong together.In Vertical Slice Architecture vs Clean Architecture: How slices fulfill layers broken promises Jimmy Bogard defines the tenets of vertical slicing When we need to add business functionality to an application, therefore each vertical slice should contains the minimum viable code it needs to implement its feature.Įach slice is encapsulated so that the application doesn’t need to know what goes on inside the slice it merely passes a Request and receives a Response. Instead of dividing code by type, kind or layer, we organise it by the change we need to make. The aim is to reduce coupling between features to only concern ourselves about a single vertical slice not N-layers, which improves maintainability. In Vertical Slice Architecture, A feature manages its data access code, domain logic and its presentation code, this way we can lowering the coupling and high cohesion between features. Code is organised by function rather than feature or business process. Heavy Coupling Inside Layers – Heavy coupling within a layer, light coupling between layers. controllers MUST talk to a service which MUST use a repository. This often requires Unit Tests to have a number of mocks or stubs created.Ībstractions Upon Abstractions – Repository pattern, Service pattern which leads back to rigid rules appearing on how code must flow e.g. Mock Heavy – Any layer that wants to talk to another layer has to be through an interface or an abstraction. Splitting off features/capabilities for things like scaling out can be a lot of effort. Monolithic in approach – The way the system is structured, like an onion, it’s typically monolithic in its approach. The following are some of the disadvantages of using the layered architecture The Elasticity and scalability rates for Layered Architecture are also fairly low due to the monolithic nature of deployments. One of the difficulties of using the layered architecture approach are its dependencies of developers having to create abstractions and its lack of architectural modularity.