Reputation: 5499
I'm developing an Android app whose architecture is based on Uncle's Bob Clean Architecture, and I've already implemented many of my UseCases/ Interactors without 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 joins the user in the room
So, should I create a single interactor ( SearchOrCreateRoomAndJoin ) or 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)
}
Upvotes: 10
Views: 5771
Reputation: 221
Name the use-case as JoinRoom (only one use-case is enough here)
class JoinRoomUseCase( searchRepository : searchRoomRepository,
createRoomRepository : CreateRoomRepository,
joinRoomRepository : JoinRoomRepository){
fun execute(param:Param){
if(searchRepository.findRoom){
joinRoomRepository.join()
}else{
val room = createRoomRepository.create()
room.join()
}
}
}
Upvotes: 0
Reputation: 944
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.
Upvotes: 8