15

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?

paxdiablo
  • 772,407
  • 210
  • 1,477
  • 1,841
  • 1
    Glenn Block explain very clearly on [here][1] [1]: http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference/101561#101561 – cuongle Aug 09 '12 at 09:10
  • 1
    Actually it isn't clear, because his MVC description is just a rewording of MVP. That description, while highly upvoted is wrong. It is more of an attempt to show that ASP.NET MVC implements both patterns. – tereško Aug 13 '12 at 01:49

1 Answers1

15

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.

tereško
  • 56,151
  • 24
  • 92
  • 147
  • How does Model2 work in PHP? Controller->View->Model Layer (different sections require different interactions: sidebar, navigation)? – Stephane Sep 28 '12 at 05:11
  • 1
    Which is why the current view can use multiple templates. You have template for navigation , for sidebar, another for document list and so on. View acquires information from model and, based on that information, decides how to display the result. Thought you might be interested in looking into HMVC pattern too. It approaches the problem from a bit different angle. – tereško Sep 28 '12 at 12:27
  • It seems like having a more active view would mean that if my view wanted xml instead of json, it would be much simpler than say having my controller handle that. – Stephane Sep 28 '12 at 16:17
  • In **MVP** the view can be somewhat active when using the _Supervising Controller_ instead of _Passive View_ – Keyne Viana Oct 09 '12 at 07:43