Clean Architecture
Organizing an app in layers where business rules don't depend on UI, frameworks or databases, and dependencies point inward.
Definition
The idea, popularized by Robert C. Martin, is that the core logic of an app should be plain code that can be tested and reused without the UI or the storage technology. On Android it usually appears in a pragmatic form: a UI layer, an optional domain layer with use cases, and a data layer with repositories. Taken too far, it produces pass-through use cases and a mapper for every layer without isolating any real logic.
In practice
CanCancelOrderUseCase is plain Kotlin used by two screens and tested with a fake clock; it knows nothing about Compose or Room.
Related terms
- Use caseA small class in the domain layer that holds one business rule or action, reused by several screens.
- Dependency inversion principleThe D in SOLID: business code defines the interfaces it needs, and details like databases and vendors implement them.
- MVVMModel-View-ViewModel: the UI observes a ViewModel that holds screen state and logic, separate from the UI code.