Clean Architecture, introduced by Robert C. Martin (Uncle Bob), aims to create systems that are:
- Independent of frameworks
- Testable
- Independent of UI
- Independent of database
Independent of any external agency
Clean Architecture emphasizes separating the concerns of different parts of the system and ensuring that each part has a clear responsibility.
.NET clean architecture as a development approach, available in a layered form to reduce dependency.
The architecture consists of several layers, each with a specific role and dependencies that flow in one direction: from the outer layers to the inner layers.
Inner most Layer is independent to its outer layer, means inner most layer does not have any references, it builds and stand independently.
Dependency Rule
The core principle of Clean Architecture is the Dependency Rule, which states that source code dependencies can only point inward. This means:
Nothing in inner circle can depend on anything in an outer circle.
Data formats and structures should also follow this rule.
Infrastructure Layer and Presentation Layer are outer most layer so these two layers does not depend on each other.
The main four layers of clean architecture consist of below layers:
- Domain Layer
- Application Layer
- Infrastructure Layer
- Presentation Layer
I have created project for better understanding, let’s Learn in detail.
I have created below Diagram for better understanding.
Key Points
a. Database implementation happens on Infrastructure layer so consider we connected to SQL database and tomorrow if requirement changes then and client says we need to change database to oracle then we can do with impacting other part of application
b. Similarly, Presentation Layer, today in this example we have used api end point and instead of it we want to use ASP.net MVC or any other UI framework we can use it without impacting rest of application.
Top comments (0)