Why package by feature first and then by layer?
Context
For those seeking to understand what vertical slice architecture is and its relationship to other architectures I recommend checking out some of my favorite articles on the topic here 👉 what is vertical slicing?
This post provides a terse overview of why you might pursue vertical slicing with a few examples.
I’ve found these notes to be valuable in quickly setting the frame for group discussions on whether vertical slicing should be used in a certain setting. Hopefully, they will help you too.
Rationale
1. Reduces information overload
After opening a directory it is the developer’s job to filter out the files that are not relevant to their task at hand. The more files to filter, the more difficult it becomes to orient themselves and start making changes quickly. Packaging by feature first promises to reduce this information overload.
2. Reduces merge conflicts
Code bases with multiple developers will often run into issues where changes end up stepping on each other’s toes. Packaging by feature first promises to reduce these merge conflicts.
3. Reduces barrier to share code
Occasionally we develop code that has incredible utility across multiple microservices. Surgically extracting useful pieces typically requires a deep understanding of the code base and is often painful. Packaging by feature first promises to reduce the barrier to sharing code across microservices by simplifying the process down to copying a single directory.