Summarized Clean Code Architecture
The people who know about the “The Clean Code Architecture” might be very well aware of Robert Cecil Martin, popularly known as Uncle Bob
Uncle Bob is an American Software Engineer, a man with a mind behind several software design principles. He is one of the author of the book “Agile Manifesto”
Before moving forward and explaining about Clean code architecture it was an important thing to tell about Uncle Bob because he is the man behind Clean code architecture too.
Uncle Bob explained about Clean Architecture in one of his book “Clean Architecture: A Craftsman’s Guide to Software Structure and Design”
Where he explains architecture with segregated layers which will help in independent testing, and independent framework, databases, and interfaces
As per Uncle Bob’s Architecture, we can segregate our code in four layers :
- Entities/domain: Entity layers consist of business logic which remains intact the entire time.
- Use Cases/ Application: This layer contains application-specific business rules and implements use cases for business logic
- Controller/Presentation/Adapters: In this layer, The software is a set of adapters that convert data from the format most convenient for the use cases and entities to the format most convenient for some external agency such as the Database or the Web
- Framework & Driver/Details: This layer is generally composed of frameworks tools such as the Database, the Web Framework, etc.
The Dependency Rule for Clean Code Architecture explained by Uncle Bob says -
Different areas of the software are represented by concentric circles.
Where, Inner circles are “Policies” and Outer circles are “ Mechanism”
The overriding rule that makes this architecture work is The Dependency Rule.
The rule says that source code dependencies can only point inwards.
Things in the inner circle will be unknown about the things in an outer circle i.e Nothing in an inner circle can know anything at all about something in an outer circle.
Uncle Bob also mentioned “You may find that you need more than just these four. There’s no rule that says you must always have just these four”
However, the only rule that applies is, Source code dependencies should always point inwards, and as you go inwards there is an increase in the level of abstraction. And low-level concrete details are in the outermost circle. Software grows more abstract as you go inwards, and higher-level policies are encapsulated.
Clean Code architecture is used when dealing with large project, In order to keep business logic intact and separating the files or classes into components that can change independently of other components
References :
https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html