Pergunta

I am using MVP for creating an android application, which takes data from server and sets to activity.

I am forced to create one presenter for each view.
Each view is unique because each view has different textviews/labels.
The presenter will read values from model and call setter method for each control in view.
For second view, I will need different presenter, as I need to call some other setter methods on the view interface.

This means view - presenter will have one to one relationship.
Is it ok for view - presenter to have one to one relation in MVP or my approach is not correct?

EDIT: I will be using one presenter for each view because I have to. Because each presenter will implement the functionality unique for each view.

However that poses reusability problem. The presenters have a lot of common code. eg calling helper to load data from URL etc. So I am planning to use either the abstract factory pattern or the strategy pattern. The problem with abstract factory pattern is , if tomorrow my presenter need to extend another class, it cannot be done because i m coding in java. So is it advisable to use abstract factory pattern in java , for the presenter group?

Foi útil?

Solução

Yes, it is fine.

Applying MVP design pattern means having MVP triplets (model-presenter-view) per every (even a bit complex) item to display. The logic goes to the model, and the presenter is there just to glue things.

Licenciado em: CC-BY-SA com atribuição
scroll top