Clean Architecture
Clean Architecture, also known as Hexagonal Architecture or Ports and Adapters, is an architectural pattern used in designing business applications. Robert C. Martin proposed it and it emphasizes the separation of concerns, maintainability, and testability. Clean Architecture aims to create a flexible, adaptable, and maintainable system over time.
Clean Architecture divides your application into five key components; let’s understand them through the example of an online bookstore:
- Entities (innermost layer): Entities are the business objects that encapsulate the core business rules. They are independent of any specific technology, database, or framework. Entities represent the “things” in the system and what they can do. In an online bookstore, a
Book
entity might have properties like title, author, price, and methods to check availability or apply discounts. - Use cases: Use cases contain the application-specific rules and...