MVC versus MVP for a WinForms app

 
80   94.6
 
 Feb 07, 2010
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 populat 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.






 
50   50
 
 27 days ago
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.
 
75   93.8
 
 25 days ago

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.
 
 
 2 days ago
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 presenter would be a better choice, but that's the opinion I favor.

( By the way a point I would like to discus about -- using especially two way binding with databound controls causes violation of MVP. What do you think ???   (No MVVM reference please which many may give ;), just purely in the context of MVP Vs MVC)
Because I think it's more like MVC.  )