Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC / MVP / MVVM What the Heck?

I recently worked on a .Net WPF project to build a retail point of sale system where I used the MVP pattern for the first time. It took me a little while to wrap my head around the change of approach but once I did that I thought that the concept rocked!

My question is this: what is the distinction between MVC, MVP and MVVM? If there is a clear distinction, are there guidelines as to when you should use one pattern over another?

If anyone can offer guidance on this, or point to article that explains the differences I'd very much appreciate it.

like image 510
Steve Avatar asked Aug 19 '09 08:08

Steve


People also ask

What is MVC MVP MVVM?

MVC (Model — View — Controller), MVP (Model — View — Presenter), and MVVM (Model — View — ViewModel) is the most popular and industry-recognized android architecture pattern among developers.

What's the difference between MVVM MVP and MVC?

References — In MVC, the View doesn't have reference to the Controller while in MVP, the View has reference to the presenter and in MVVM, the View has reference to the View-Model. Entry Point — For MVC, the entry point to the application is the Controller whereas, for MVP and MVVM, the entry point is the View.

What is MVP and MVC?

MVC (Model — View — Controller) and MVP (Model — View — Presenter) are the two most popular android architectures among developers.

What is MVC and MVVM?

MVC (Model — View — Controller) and MVVM (Model — View — ViewModel) are the two most popular android architectures among developers.


2 Answers

It can be hard to grok the differences between patterns by looking at a particular pattern implemented in a particular framework. This msdn article WPF MVVM makes reference to Martin Fowlers original articles which explain a pattern as a general approach:

Back in 2004, Martin Fowler published an article about a pattern named Presentation Model (PM) [...] consider MVVM to be a specialization of the more general PM pattern, tailor-made for the WPF and Silverlight platforms.

So to understand different patterns it is useful to look at Martin Fowler's descriptions of different approaches. His Passive View pattern is the MVP approach. His Supervising Controller pattern is the MVC approach. His Presentation Model pattern is the MVVM approach. This older article takes about the evolution of such patterns.

It may also help to look at implementations in different languages. The article Implementing event-driven GUI patterns using the ZK Java AJAX framework contrasts the three of Martin Fowler patterns mentioned above in a modern Java framework. Even though its a different language and a different framework from WPF it may help to see the pattern rather than the implementation of the pattern to see it done in a different language.

like image 40
simbo1905 Avatar answered Sep 21 '22 12:09

simbo1905


Microsoft's Application Architecture Guide describes MVC and MVP, and explores the differences between the two.

http://www.codeplex.com/AppArch

This MSDN article describes MVVM and it's evolution.

http://msdn.microsoft.com/en-us/magazine/dd419663.aspx

like image 149
JustABitOfCode Avatar answered Sep 21 '22 12:09

JustABitOfCode