Dofactory.com
Dofactory.com
 Back to list
Views:   30.7K
Replies:  4
Archived

MVP and MVC when to use which?

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.
Trey Henlon, Jun 30, 2010
Reply 1
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

Christian Jacob, Aug 13, 2010
Reply 2
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
Rajesh Pillai, Jul 31, 2010
Reply 3
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
Rajesh Pillai, Jul 31, 2010
Reply 4
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.
Christian Jacob, Jul 01, 2010
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.