Vertical slices
Vertical slices is an architectural pattern standing in opposition to layered architecture. Instead of organizing things into technical layers, such as persisitence, domain, presentation, APIs etc., vertical slices suggest organizing the code around features or group of features.
The tagline for vertical slices is: it minimizes coupling between the slices, while maximizing coupling inside a slice.
Pros
- Every slice can decide its layering for itself. Many won’t need high complexity, but some will.
- Easier to assign ownership on a per-directory basis, as done with Github’s CODEOWNERS file
- It’s easier to asses what the application does by looking at the list of slices (features) than a list of layers (technical concepts)
Solutions that somewhat do vertical slicing
- Hanami slices
- Phoenix contexts, but that’s not a proper slicing, because it’s only sliced at the core business logic layer. Also, by default it does not promote layering inside the slice.
Sources and further reading
- Vertical Slice Architecture by Jimmy Boggart from 2018, considered somewhat canonical
- Why Vertical Slices Won’t Evolve from Clean Architecture argues that you have to choose to do vertical slicing, you won’t just evolve into it from the layered architecture