How Does This Help Me Build Maintainable Software?
Call it clean architecture, hexagonal architecture, or ports-and-adapters architecture – by inverting our dependencies so that the domain code has no dependencies to the outside, we can decouple our domain logic from all those persistence and UI-specific problems and reduce the number of reasons to make changes throughout the codebase. And fewer reasons to change means better maintainability.
The domain code is free to be modeled as best fits the business problems while the persistence and UI code is free to be modeled as best fits the persistence and UI problems.
In the rest of this book, we will apply the hexagonal architecture style to a web application. We'll start by creating the package structure of our application and discussing the role of dependency injection.