Clean Architecture
We have always heard and talked about N-Tier and N-Layer architecture along with SOLID and SOC, but as the size of application along with complexity has changed over a period of time do has application architecture. Also since teams have adopted agile, releases are much more frequent than they used to be a few years back.
In the light of the changing landscape, it is important to structure your application design in a way to give best practices, manageable code, loosely coupled features/functionality, and the least possible change propagation into various layers of the application.
Popular architecture:-
- Layered/N-Tiered architecture
- Monolithic architecture
- Microservices architecture
- Event-driven architecture
- Service-oriented architecture
What is Clean Architecture:-
Clean architecture is another name for Onion architecture, it can be viewed as an onion that consists of various application layers, can be primarily divided into 2 parts i.e Core and Peripheral layers.
Domain/Entities Layer:-
The entities/domain layer consists of domain entities and nothing else, it has no dependencies and consists of only POCO/POJO.
Application Layer:-
This layer consists of various different components as below:
1) Contracts
The contract layer as the name suggests consists of various contracts like repository interfaces, these interfaces will be implemented in the infrastructure layer.2)Features
These are various use cases that we are going to implement in the application. In the case of CQRS, it will consist of all the commands and queries in a structured folder format.
- Mocking is easy which makes unit testing easier.
- The database can be easily changed by changing only the infrastructure layer.
- Very clear division of responsibility between layers.
- The same architecture can be used in any technology.
Comments
Post a Comment