MVP and MVC when to use which?

 
72   96.0
Jun 30, 2010
 
When moving beyond the code-behind kind of coding style you run into two common patterns: MVP and MVC.
I kind of have an idea what the differences are, but my question is twofold: 

 1) What specific issues does MVP address that MVC cannot?
 2) When would I use MVC over MVP?

BTW: I am developing Windows Forms applications, which I believe seems to favor MVP.

Thanks.



555   99.9
Jul 01, 2010
Hey there,

Awesome that you sit down and really think about different MVx approaches and when to use which!

I suggest reading an article that is written some years ago and that perfectly describes what both are about and what might be the draw backs in implementing an MVC based pattern in a Windows Forms application:

http://aviadezra.blogspot.com/2007/07/twisting-mvp-triad-say-hello-to-mvpc.html

You can also directly download a PDF paper containing the article in a more printer friendly way here:
http://www.object-arts.com/papers/TwistingTheTriad.PDF

Further research and also using the term "twisting the triad" will result in a couple of interesting articles to read that always addresses your question.

The most often heard result is this:
  1. Do you develop a web application? Learn about MVC.
  2. Do you develop a winform application? Learn about MVP.
  3. Do you develop a WPF application? Learn about MVVM.
Hope that helps you... I resisted in telling you everything I do personally know about that topic, cuz the articles mentioned above will most probably do a better job. ;-)

Best regards,
-Chris.
 2 comments
 
Great post! As a side note, I use MVP(Passive View) for both WinForms and WPF apps. This has worked out quite nicely. Davy Brion has a series of posts on how he uses a modified variant of MVP with WPF (http://davybrion.com/blog/2010/08/mvp-in-silverlightwpf-series/). However, as Chrisitan mentioned, MVVM is the most used pattern for WPF and the one recommended by MSFT. --- Robert Blixt  Aug 09, 2010
 
Got a 404 for the second link. Go to http://www.object-arts.com/downloads/downloads.html and then click on "Technical Papers" to download the PDF. --- Torsten Weber  Feb 02, 2011

1,364   100.0
Jul 31, 2010
Chris, has nicely summarized.  Besides on one of my previous projects which was a windows based app, we had gone with MVP.  The primary reason was we knew moving down the line, the app needs to be ported over to the web.

And now the time has come and MVP seems to be the right decision as we now only need to swap our views.  This is a big app around 350+ forms, 250 tables and around 400 reports.

So, MVP is better for winforms based apps and also will be useful in case in future if you need to move to web. 

Regards,
Rajesh Pillai

555   99.9
Aug 13, 2010
Even when using an MVP approach for instance on WinForm projects, you need to know what suits your needs better: A passive view or a supervising controller. The flatter allows the view to communicate directly with the model. This is a scenario which is best used in cases when you implement some sort of databinding and when the "shortcut" makes your code easier to understand and more intuitive to work with.

Microsoft has a nice article on this:
http://msdn.microsoft.com/en-us/library/ff647543.aspx

Within the context of web development, you will find a patterns & practices page on codeplex diving deep into the Model View Presenter concept here:
http://webclientguidance.codeplex.com/wikipage?title=MVP_landing_page&ProjectName=webclientguidance


1,364   100.0
Jul 31, 2010
Chris, has nicely summarized.  Besides on one of my previous projects which was a windows based app, we had gone with MVP.  The primary reason was we knew moving down the line, the app needs to be ported over to the web.

And now the time has come and MVP seems to be the right decision as we now only need to swap our views.  This is a big app around 350+ forms, 250 tables and around 400 reports.

So, MVP is better for winforms based apps and also will be useful in case in future if you need to move to web. 

Regards,
Rajesh Pillai