Clean Software Architecture
(Redirected from Clean architecture)
Jump to navigation
Jump to search
A Clean Software Architecture is a software architecture style that aims to separate the core business logic of an application from external dependencies such as databases, frameworks, and UI technologies.
- Context:
- It can (typically) be organized into four layers:
- Clean Architecture Entities: Representing the core business objects of the application.
- Clean Architecture Use Cases: Encapsulating the business logic of the application.
- Clean Architecture Interfaces: Defining the behavior of external dependencies.
- Clean Architecture Frameworks and Drivers: Implementing the concrete details of external dependencies.
- It can (often) follow the principle: "High-level modules should not depend on low-level modules; both should depend on abstractions."
- It can be implemented effectively in Python using a variety of frameworks and libraries, including Dependency Injection Frameworks, Object-Relational Mappers (ORMs), and Web Frameworks.
- It can offer several benefits, such as increased maintainability, improved testability, and enhanced adaptability.
- It can be learned from resources like Uncle Bob's Clean Architecture book, articles on Clean Architecture in Python, and the Python library 'python-clean-architecture.'
- ...
- It can (typically) be organized into four layers:
- Example(s):
- A Clean Architecture for aWeb Application, where the UI can be changed without altering the underlying business logic.
- A Clean Architecture for an Enterprise Application, enabling easier adaptation to different technology stacks.
- A Clean Architecture for an LLM-based Chatbot API-based Service, facilitating the scalable and maintainable integration of natural language processing capabilities within diverse application environments.
- ...
- Counter-Example(s):
- A Monolithic Architecture in Python, where business logic, UI, and database access are heavily intermingled.
- A tightly coupled Python system where changes in external frameworks or UI require significant changes to the business logic.
- See: Software Design Principle, Layered Architecture, Robert C. Martin, Python Programming.
References
2023
- Bing Chat
- Clean architecture is a software design pattern that follows the principles of clean code and implements SOLID principles. It was first introduced by Robert C. Martin, also known as "Uncle Bob," in 2008 ¹. The concept has since grown in popularity, and programmers have developed many subcategories of clean architecture, such as hexagonal architecture, onion architecture, and screaming architecture, among others ¹³.
Clean architecture is designed to make it easier to create stable apps even when outer elements such as UI, databases, or external APIs are always changing ¹. It's essentially a collection of best practice design principles that help you keep business logic, or domain logic, together and minimize the dependencies within the system ¹. If followed, clean architecture lets software architects decouple components so they become isolated enough to be durable and easily changed without remaking the system ¹.
- Source: Conversation with Bing, 11/19/2023
- Clean architecture tutorial: Design for enterprise-scale apps. https://www.educative.io/blog/clean-architecture-tutorial.
- A Detailed Introduction to Clean Architecture - NDepend Blog. https://blog.ndepend.com/introduction-clean-architecture/.
- The Clean Architecture — Beginner’s Guide - Better Programming. https://betterprogramming.pub/the-clean-architecture-beginners-guide-e4b7058c1165.
- A quick introduction to clean architecture - freeCodeCamp.org. https://www.freecodecamp.org/news/a-quick-introduction-to-clean-architecture-990c014448d2/.
- Clean architecture is a software design pattern that follows the principles of clean code and implements SOLID principles. It was first introduced by Robert C. Martin, also known as "Uncle Bob," in 2008 ¹. The concept has since grown in popularity, and programmers have developed many subcategories of clean architecture, such as hexagonal architecture, onion architecture, and screaming architecture, among others ¹³.
2012
- (Martin, 2012) ⇒ Robert C. Martin (2012). The Clean Architecture. In: The Clean Code Blog.
- NOTES:
- It emphasizes the importance of separating concerns through the division into layers, ensuring the software is organized around its business logic rather than its technical details.
- It achieves independence from frameworks, allowing the architecture to use frameworks as tools without being constrained by them, facilitating flexibility and adaptability.
- It enables testability of business rules without reliance on external elements like UI, database, or web servers, promoting robust and reliable software development practices.
- It ensures the UI can be changed or replaced without impacting the business rules, supporting multiple interface strategies with minimal disruption.
- It allows for database independence, making it possible to switch between different types of databases without affecting the application's core business logic.
- It maintains independence from any external agency, meaning the business rules do not have to be aware of or interact directly with external systems or data formats.
- It adheres to the Dependency Rule, which mandates that dependencies within the codebase can only point inwards, from outer layers towards the inner layers, thereby preventing coupling between business logic and external concerns.
- NOTES: