Clean Architecture Flashcards
Clean architecture helps to manage
business logic and interaction with it
The Clean Architecture was written by
Robert Martin (Uncle Bob)
What are entities?
business logic of application
What are use cases?
usage methods
Use cases help to make
entities out of data stream or vice versa
Use cases are also called
interactors
What are Interface Adapters?
Collection of interfaces that help to convert data to work with entities and use cases
What does belong to Interface Adapters?
Presenters and Controllers
What are the Frameworks and Drivers?
Place where details are stored
Examples of Frameworks and Drivers?
UI, instruments, database, frameworks
Clean Architecture is
ideology like Material Design
Meaning of Clean Architecture is
building appropriate dependencies between layers
Building appropriate dependencies between layers is
dependency rule
Dependency rule of Clean Architecture is
each layer should have dependency of inner layer not outer layer
If system is built according to dependency rule, it is
easier to maintain the system
Changes in outer layers do not influence
inner layer
Clean Architecture includes
4 layers, but it is not compulsory
Each layer should have its own
responsibility
According to Clean Architecture, system should be
1. be testable2. should not depend on UI3. should not depend on DB4. should not depend on external frameworks and libraries5. should not depend on external services
Those 3 layers are
presentation layer, domain layer, data layer
Presentation layer can
MVP or MVVM pattern
Domain layer contains
regular java objects: classes, interfaces, use cases
Interactor is
class have one responsibility working with data
Example of Interactor
For example we have User class. We can create UserInteractor which has editUser method.
Data layer provides
with data
Repository can get data from
disk, cloud, memory
Repository interface is located in
domain layer
domain layer does not know about
presentation
Data knows only about
domain
Presentation layer knows about
domain and data layer
Domain module is
java module
data and presentation modules are
android module
What is data flow on Clean Architecture
View -> Presenter -> Use Case -> Service -> Repository
Example of Interactor
For example we have User class. We can create UserInteractor which has editUser method.
Data layer provides
with data
What are the advantages of Clean Architecture?
1. modularity2. dependency rule3. testability4. domain layer5. in presentation layer, any MV-pattern can be used6. great community, guides, amount of source code
What are the disadvantages of Clean Architecture?
1. excessive amount of classes2. higher entry level
When to use Clean Architecture?
1. a lot of business logic2. large application: more than 10 screens3. testability is required4. app should be maintained further
When not to use Clean Architecture?
when project is small and does not have business logic