4

I am going to develop a winform project of considerable size. I am planning to use Entity Framework as ORM tool. Now I am searching for an architecture(MVC/MVP/MVVM etc..) to implement all these. Firstly there are few choices for n-layered architecture for windows forms and most those I get are written prior to EF came into market. I got a framework called Rocket Framework from codeplex(http://rocketframework.codeplex.com)

I have looked around it but am skeptical that it will accommodate a wide range of requirements. If anyone has already discovered the wheel already, please guide me through. Also if the existing architectures prior EF4 can accommodate it than also I can give it a try. Ideas please!

bikram s.
  • 195
  • 2
  • 12

3 Answers3

6

Well your choices is influenced by the technology you're using. Some technologies make a certain pattern natural to do and thus if you (and every developer) don't explicitely design and care about this you'll end up with what feels most natural. On WinForms the most natural pattern is MVP. You have your view that you can layout in the designer and your code-behind file becomes the presenter, essentially combining view and presenter in one class (it's a 1:1 relationship anyway). For web applications on the other hand MVC is a natural pattern since your web server already acts as a controller. Finally MVVM is supported very well in WPF, although you could fall towards MVP there as well if you start using the code behind file a lot. But relying on DataBinding instead can make you forget to use the code behind file. A good article I read about this is here. Of course you can realize MVVM with WinForms, read this link for a good example.

From the point of testability MVVM is perceived as the best pattern since your view model (and therefor the behavior of your view) can be tested without an actual GUI. MVP however is easy to understand and realize, doesn't require complex bindings and gives you most control over what is happening (e.g. event suppression).

Andreas
  • 6,215
  • 2
  • 29
  • 45
5

WinForms applications are mostly developed with MVP pattern. The original MVC is not used very much - only its Model-2 variant (for example ASP.NET MVC) for web applications. MVVM is used primarily with WPF and Silverlight.

Neither of these patterns affects how you use Entity framework - they are not data access related patterns.

Ladislav Mrnka
  • 349,807
  • 56
  • 643
  • 654
  • 1
    Thnx..Ladislav, I appreciate the straight forward answer. Now things are clear to me and I am giving a try to MVC# - http://www.mvcsharp.org – bikram s. Sep 30 '11 at 14:50
2

After a lot of R&D and extensive study I finally settled here: http://cgeers.com/2008/12/14/mvp-model-view-presenter/#comment-718 It is an MVP architecture written by Christophe Geers. It supports all I needed- Architecture for winform, web portability support, Entity Framework. Really nice and easy to use.

Additional reading: http://www.cerquit.com/blogs/post/MVP-Part-I-e28093-Building-it-from-Scratch.aspx

bikram s.
  • 195
  • 2
  • 12