jeudi 17 mai 2018

MVP design pattern practical observations

I am trying to understand MVP design pattern practically and went through this link and few other links and made some observation.I want to know that are all below observations correct for implementing MVP design pattern practically?

1.Activity,fragments and our xml layouts will be part of View.

2.Our pojo classes or the classes which are responsible for fetching data,making api call or calling web services are part of Model.

3.We create an interface which contains abstract methods for various events we need to perform on View or various events for the lifecycle of view.Activity/Fragment will implement that interface and pass its reference to Presenter constructor.

4.Presenter will have reference to both View and Model.Its contructor will contain reference to an interface which activity implemented and it will create an object of Model

5.Whenever an action is performed on View or for any lifecycle callback of view, a method of Presenter is called from View.That method will interact with both Model and View as per requirement.It will call method of Model and will call the method of interface that activity implemented so both model and view can perform action in their classes.

Aucun commentaire:

Enregistrer un commentaire