Search code examples
model-view-controllerdesign-patternsmvvmmvp

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?


Solution

  • 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.