I am using MVP pattern for my android project. However, I am confused for a reason. In MVP, a presenter will communicate with the model for data. Now as my application is a little bit large so I need to follow interactor instead of single data manager where all data will supply by the data manager.
So for the different type of entity I have a different repository. For example, I have a UserRepository and an ActiveServiceRepository. So after login, I need to fetch user information from user repository and list of active service from ActiveServiceRepository.
Now according to clean code architecture, it will be better if I use GetUserInfoInteractor and GetActiveServicesInteractor according to single responsibility principle. So each repo will have the same number of interactor based on methods.
But problem is, the login presenter needs to use two separate interactors(GetUserInfoInteractor,GetActiveServicesInteractor). Again if it requires more then two interactors, then number will increase. However, the benefit is this interactor can be used in any place by any component.
Now forget about separate interactor for communicating with a repository. We can create a LoginInteractor and inside login interactor, we have two separate method getUserInfo() and getActiveServices() where userInfo will use userReposiotry directly and active service will use ActiveServiceRepository directly. As a result of our presenter just need to interact with loginInteractor. So if I need to implement any new feature then I will put that in loginInteractor.
In the case of the first solution, it is very easy to convert the whole code base into clean code architecture. But I could not decide which flow I should follow?
Aucun commentaire:
Enregistrer un commentaire