Android MVP - which model to view

I am using the MVP design pattern. The models that I present in my opinion are currently POJOS, which are models for my local Realm database. In doing so, they annotated members related to the database. Would it be better to use a presenter to map the database models returned from the interactor to models that contain only the data that the view should use (have a separate POJO model for my presentation)? Or is it a great practice to convey the views of my db models?

Thanks.

+5
source share
1 answer

The question you have to ask is

If I remove Realm from my application, I have to make changes to my if I use these entity classes

If there is no answer, I see no problem with these objects moving to your view. If, however, they are tied to the kingdom in such a way that you need to change your mind, then this will break the unleashed idea of ​​MVP.

I personally often do ViewModel anyway. The reason is because I want to minimize the number of separate calls between my presenter and my presentation. Ideally, your view should be as close as possible to the methods:

setLoadingUi(); setContentUi(ViewModel model); setEmptyUi(); setErrorUi(); 

Although this is not always possible if you have various view calls, such as setConfirmButtonText , that associate your presenter with great knowledge about your presentation. What happens when you change the button to scroll ... your presenter will need to change, as well as your appearance.

Hope this helps!

+2
source

All Articles