22: Clean Architecture

Clean Architecture Blog

Similar Architectures

  • Hexagonal Architecture (Ports & Adapters)

  • DCI

  • BCE

They all have the same objective:

  • The separation of concerns achieved by dividing the software into layers.

Each architecture produces a system with the following characteristics:

  • Independent of Frameworks

  • Testable

  • Independent of the UI

  • Independent of the database

  • Independent of any external agency.

Entities

  • 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.

Use Cases

  • 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.

Interface Adapters

  • 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.

Last updated