Dependencies pointing inward.
WHAT THE CORE IDEA IS
Business rules at the centre, with everything else depending on them, and not the reverse.
WHAT THAT MEANS PRACTICALLY
The domain knows nothing about the database, the web framework, or the interface.
WHY THAT MATTERS
Those are the things most likely to change, and the business rules are the thing most valuable to preserve.
WHAT THE LAYERS TYPICALLY ARE
- Entities: core business concepts
- Use cases: application-specific rules
- Interface adapters: translation to and from the outside
- Frameworks and drivers: the database, the web, external services
WHAT THE DEPENDENCY RULE IS
Dependencies point inward only.
HOW OUTER LAYERS ARE CALLED
Through interfaces defined in the inner layers, implemented outside.
WHAT THAT ENABLES
Testing business rules without a database Replacing infrastructure without touching business logic
WHAT IT COSTS
More indirection More code for simple operations A learning curve
WHEN IT IS WARRANTED
Complex business rules, long-lived systems.
WHEN IT IS NOT
Simple applications where the business logic is trivial.
WHAT TO TAKE FROM IT REGARDLESS
Keep business rules independent of frameworks.