I'm developing an Android app whose architecture is based on Uncle's Bob Clean Architecture.
I've already implemented a lot of my UseCases/ Interactors whithout problems, until now.
I have the following use case:
Search Room
Main Success Scenario
Extension
Room Not Found
a) System creates a new room based on given parameters
b) System join user in the room
My question is: Should I create a single interactor ( SearchOrCreateRoomAndJoin ), or should I create three interactors ( SearchRoom, CreateRoom and JoinRoom ) and combine them according to my use case description?
Example:
Room room = searchRoom.execute(roomOptions)
if(room != null){
joinRoom.execute(room)
}else{
Room room = createRoom.execute(roomOptions)
joinRoom.execute(room)
}
It's import to say that in some points of my app I execute some interactors like SearchRoom
Interactor calling multiple workers. When Interactor needs to perform more than one task, having multiple workers to execute each one of the task is the recommendation of clean architecture — confirming SOLID principle.
In Clean Architecture "use case" and "interactor" means the same: it is the component which contains business logic. The presenter in this architecture does not contain any business logic.
The purpose of the Use Cases is to request data to repositories and turn into something usable for the View. Because of that, we are mapping the Crypto model from the Repository to a new view model named CryptoViewModel (I am not very creative 😅).
Clean architecture vs. The logical layers of this style are as follows: Presentation layer ( accounts for the presentation to the user) Business logic layer (contains the business rules) Data access layer (processes the communication with the database)
In my opinion, you should develop the three interactors in order to respect the Single Responsability Principle. If you do that, you increase the maintainability and reutilization of the code, because you could use these interactors separately in other scenarios.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With