22: Clean Architecture
Last updated
Last updated
Hexagonal Architecture (Ports & Adapters)
DCI
BCE
The separation of concerns achieved by dividing the software into layers.
Independent of Frameworks
Testable
Independent of the UI
Independent of the database
Independent of any external agency.
Encapsulate enterprise-wide (or domain) Critical Business Rules.
Can be an object with methods, or it can be a set of data structures and functions.
Can be used by many different applications.
Business Objects of the Application/Domain.
Encapsulate the most general, high-level rules.
Least likely to change when something external happens.
Layer contains Application-specific business rules.
Use cases orchestrate the flow of data to and from the entities, and direct those entities to use their Critical Business Rules to achieve the goals of the Use Case.
We do NOT expect....
Changes in this layer to affect the Entities.
This layer to be affected by changes to externalities such as the database, the UI, or any of the common frameworks.
Changes to the operation of the application will affect the use cases and software in this layer.
A set of adapters that convert data from the format most convenient for the user cases and entities, to the format convenient for some external agency (database or web).
Also in this layer is any adapter necessary to convert data from some external form (external service) to the internal form used by the use cases and entities.