1

I have never used MVC before and would like some advice.

I have actually already written quite a bit of code, but looking at it, it seems to be quite highly coupled between classes and there is a lot of code written on the actual main form of the winform. I am a University student, recently started on a 12 month placement, so do not have much real world experience.

My system is effectively a WinForm GUI that has, amongst other things, a treeview that is popualted at load via an event. And then when the user clicks on a node, it gets a datagridview from a dllplugin (which obtains the data from an Oracle DB via a perl script.

My question, is would MVC apply in this circumstance, and would anybody have any good advice/resources on how I can now, post-design to implement it?

Thanks.

Darren Young
  • 10,972
  • 36
  • 91
  • 150

3 Answers3

2

The MVP pattern is more adapted to WinForms applications. Here's a nice article you may take a look at.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
1

Received wisdom is that MVC is good for the web but has some constraints when operating in a desktop environment (I'm not sufficiently experienced in applying this sort of pattern in either context to make a worthwhile judgement).

The pattern that Microsoft (for one) are pushing for forms use is MVVM - which is Model View View Model - and it provides a similar set of benefits in terms of separation and testability. Even allowing that I could wish I knew more I can see what and why, especially if you're looking at WPF (and Silverlight) but in any context where you're trying to ensure separation.

Murph
  • 9,985
  • 2
  • 26
  • 41
0

The MVC pattern can work well with WinForms, see this question.

There are lot of related pattern to choose from; in the case of WinForms (unlike WPF) there is no clear winner.

Partly this is due to everyone having different aims, do you care most about:

  • Code reuse between Forms in the UI
  • Being able to support form the one UI system
  • Easy unit testing
  • Etc
Community
  • 1
  • 1
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
  • I'm not sure if I am using some variation already. One aspect of my application is extracting information from Excel. Dependant on the data, different methods are applied. These methods are written in dll's which interact with the GUI through an interface I designed. So the user clicks a button on the GUI, which interacts with the DLL, which in return, returns back sone status information. Is this an example of MVC? Thanks. – Darren Young Nov 10 '10 at 14:44