Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between MVC, MVP and MVVM?

From what I can gather, the first two don't seem that different. Whether it's called a controller or presenter, it still seems to have the same mediation functions.

MVVM seems a little different in that the controller seems to be more of a part of the framework, such as with XAML bindings.

What is the "Cliff's Notes" explanation of the differences?

like image 906
paxdiablo Avatar asked Aug 09 '12 06:08

paxdiablo


People also ask

What is the difference between MVC and MVVM?

KEY DIFFERENCEIn MVC, controller is the entry point to the Application, while in MVVM, the view is the entry point to the Application. MVC Model component can be tested separately from the user, while MVVM is easy for separate unit testing, and code is event-driven.

What is the difference between MVP and MVVM Architecture explain the working of each?

Difference Between MVP and MVVM Design PatternMultiple View can be mapped with single ViewModel. The Presenter has knowledge about the View. ViewModel has no reference to the View. Model layer returns the response of the user's input to the Presenter which forwards it to View.

Why MVP is better than MVVM?

But the major difference is communication back to the view. Whereas in MVVM there is usually a separate publisher for each piece of data, in MVI a single object defining the entire state of the view is published.


1 Answers

The difference is in way how data from model layer ends up in the view instances.

  • in classical MVC (and also in Model2 MVC) view is active structure. It requests information from model layer. Controller only changes the state of model layer and view.
  • in MVP the view is passive. Instead presenter request information from model layer and passes it the view. You can read more extensively on about MVP pattern here.
  • in MVVM is similar to MVP, but the viewmodel has to manipulate the information before passing it to view.

The difference between MVP and MVVM is in the development process. You would use MVP pattern, when creating presentation layer for a known model layer.

But you will have to use MVVM, if you have a preexisting (or for some reason - un changeable) user interface and preexisting (or unchangeable) model layer. And you have to make them work together. That's where viewmodel comes into play.

like image 199
tereško Avatar answered Oct 19 '22 14:10

tereško