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 on 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 code base. And fewer reasons to change lead to better maintainability.
The domain code is free to be modeled as best fits the business problems, while the persistence and UI code are free to be modeled as best fits the persistence and UI problems.
In the rest of this book, we’ll 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.