MVP Pattern

You will learn about the MVP pattern in detail with the help of a coding example in this lesson.

What is the MVP pattern?

The MVP pattern stands for model view presenter. It is derived from the MVC pattern, which focuses on the user interface. MVP however, is focused on improving the presentation logic.

It consists of three components:

  • Model: provides the data that the application requires, which we want to display in the view

  • View: to display the data from the model, it passes the user actions/commands to the presenter to act upon that data

  • Presenter: acts as the middle man between the model and the view. Retrieves data from the model, manipulates it, and returns it to view for display. It also reacts to the user’s interaction with the view.

What’s the difference between MVP and MVC?

MVC MVP
The controller acts as the mediator between the model and the view The presenter acts as the mediator between the model and the view
Controller can share multiple views The presenter has a one to one mapping with the view. If the view is complex, it can use multiple presenters
The view can also communicate directly with the model by observing it for changes and updating itself accordingly The model and the view are more separate in this pattern as the presenter reacts to user actions by retrieving and manipulating model data and returning it to the view for display

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.