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

MVC versus MVP for a WinForms app

I am starting up a relatively small project using WinForms. I have been reading up on patterns and MVC versus MVP.  I see that MVC is widely used and very popular in Web development (hence the new ASP.NET MVC platform). However, for a WinForms app, I believe there are advantages to using MVP. Can someone confirm this and explain why?  Thanks.
Juan Perez, Feb 07, 2010
Reply 1
It is hard to say which ones are better, but from the separation of concerns principle it is preffered MVC over of MVP. It is important how you think your architecture and especially what your application does.
Nicolae Dima, Mar 30, 2010
Reply 2
Nirajan Singh has given a pretty decent reply, so rather than adding anything I will just present my viewpoint.

For WinForm app MVP is a better choice, especially considering testability.

Well as far as intelligent view is concerned, I will partially agree, as it's an open debate that where to put most of the logic. And considering testability, I think heavy use of the Presenter would be a better choice, but again, that's my opinion.

Syed Saqib Ali Tipu, Mar 10, 2010
Reply 3

Both in MVC and MVP the presentation layer consists of view objects, and application logic consists of controller\presenter objects. For each view object a corresponding controller\presenter exists and vice versa. And although MVC and MVP are based on a common 3-tier principle: views process only presentation needs and controllers\presenters handle application logic, these patterns have two major differences:

  1. In MVC controllers receive and process user input, but in MVP views receive user input and then merely delegate processing to the corresponding presenters. That is why MVP pattern better fits modern UI environments (Windows/Web forms) where view classes themselves handle user gestures.
  2. In MVC controllers affect their views by changing the intermediate presentation model, which the views are subscribed to (by observer pattern). This makes views pure observers without direct access to them. MVP on the other hand violates this "pure observer" rule by providing a direct link from a presenter to its view. This makes MVP more handy as compared to MVC.
Nirajan Singh, Feb 15, 2010
Reply 4
I am struggling with this a bit myself. From what I've read (not tried it yet) the impetus behind MVP was to "smarten up" the view. I believe in a pure MVC patten, we wouldn't want to take advantage of things on the client side like Data Binding or any type of data entry validation. With MVP, you get to use more of the richness provided by the platform.

I'd love to hear how you end up tackling this issue. I did find one website (don't have the link handy) that talked about using MVC / MVP in a WinForms world.
Derek Lawless, Feb 12, 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.