Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Model-View-Presenter and Model-View-Adapter?

I'm trying to understand whether there's a difference between the Model-View-Presenter and Model-View-Adapter patterns, and--if so--what that difference is. I haven't found any online resources that compare/contrast them, so I'm not even sure whether they're actually distinct.

The descriptions I've found of them sound essentially identical to me. From what I've gathered, in both cases the control flow is basically:

View <-- Adapter/Presenter --> Model
(where Adapter/Presenter can also respond to events from View and Model)

View: the UI
Adapter/Presenter: main logic; mediator between the UI and the data model
Model: the data model

The Adapter/Presenter "knows about" the View and the Model, but the View and the Model don't know about anyone other than themselves.

I expect that there's a subtlety that I'm completely missing here. What is it?

like image 315
Matt Tsōnto Avatar asked Mar 23 '13 15:03

Matt Tsōnto


People also ask

Whats the difference between MVP and MVC?

User Input: In MVC, user inputs are handled by the Controller that instructs the model for further operations. But in MVP, user inputs are handled by the view that instructs the presenter to call appropriate functions. Type of Relation: A many-to-one relationship exists between the controller and view.

How does Model View Presenter work?

Presenter: This layer works as a middle-man between view and model. It fetches data from the model layer, format the data and return to the view. It also reacts to user interactions through view interface and update the model.

What does the presenter do in MVP?

The Presenter is responsible to act as the middle man between View and Model. It retrieves data from the Model and returns it formatted to the View. But unlike the typical MVC, it also decides what happens when you interact with the View.

What is the MVP design pattern?

In the MVP design pattern, the presenter manipulates the model and also updates the view. In MVP View and Presenter are completely decoupled from each other's and communicate to each other's by an interface.


1 Answers

The only thing I can think of is MVA is generally associated with having multiple adapters between a view and model. While there's nothing stopping you from doing that in MVP, I think MVP implies a strong triad.

Update (years later): in retrospect, I believe a key difference would be control flow. In MVP, the View triggers/creates/calls the Presenter, which delegates to the model and responds back to the View. In MVA, when messages come in, an Adapter is chosen, which then mediates between the Model and View. Because the MVP View triggers/creates/calls the Presenter, choosing between multiple Presenters (as an Adapter is chosen) is not a straightforward fit.

like image 97
rich remer Avatar answered Oct 10 '22 20:10

rich remer