Can someone please explain in a way as simple as possible what the Model View Presenter pattern is? What is the difference with Model View Controller ? Which is best or for which purpose ?
Data (model) and UI (view), only communicate with one another through an intermediary (the presenter) . The presenter contains the bulk of the business logic, while the view focuses on how to display the data. The controller responsibility is now split between the view and presenter.
Model–view–presenter (MVP) is a derivation of the model–view–controller (MVC) architectural pattern, and is used mostly for building user interfaces.
The role of the Presenter class is to keep the business logic of the application away from the activity. Below is the complete step-by-step implementation of this android application. Note that we are going to implement the project using both Java and Kotlin language.
Model View Presenter and Model View Controller both try to solve the same "seperation of concerns" problem.
The primary difference you'll find is that Model View Controller (MVC) is often implemented with some coupling between the view and some model of some sort - thereby a given view is specifically purposed to provide a visualization of a given object (model).
In the Model View Presenter pattern you generally find that the Presenter takes care of working with the model, and deciding what information from it will be needed to form some sort of visualization.
In this diagram, arrows represent dependencies:
Typically you hear this pattern discussion come up when discussing the ASP.NET MVC framework, and come across information regarding the MVP pattern and it's implementation in ASP.NET WebForms. It is common in my experience that it is believed that WebForms is in and of itself an MVP patterned framework - this is not true. WebForms does however make it very easy to implement an MVP pattern - your best resource for this would be to investigate the Web Client Software Factory from the Patterns and Practices team.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With