tags:

views:

582

answers:

10

I wish to learn the MVC paradigm and apply it to GUI development (in C#.NET, at least at first, but I think I'd like to apply it elsewhere too). Pretty much every tutorial I've seen so far assumes that if you are thinking MVC, you must be doing web development, and they examine MVC solely from within a web context. I don't give a hoot about web development.

Does anyone use MVC in a non-web context? It seems like it'd be ideal for GUI development -- separate the presentation from the underlying data model. But I'm just learning so I don't know. Any pointers to tutorials or reference works would be appreciated, thanks.

+1  A: 

Swing in Java uses MVC. Might be worth checking out?

cagcowboy
+6  A: 

Check out the book Head First Design Patterns. It's an excellent guide to implementing design patterns and has a solid example of MVC as well.

Jekke
Yeah this book is excellent.
James McMahon
+1 For Head First Series!
Refracted Paladin
+1 Yep, good book.
John Gietzen
A: 

This pygame tutorial uses MVC. Throwing together a small game could be a fun way to get a grasp on the design pattern.

James McMahon
A: 

Mac programming in Objective C and Cocoa is generally an MVC model.

It's not C#/.NET, but if you wanted to invest the time to read about it, you might get some ideas.

Erv Walter
+1  A: 

I don't have any links to share, but I've been experimenting with this lately. What I did was create a controller and a controller interface. The controller interface actually implemented several other interfaces to keep all of the unique functionality clearly separated.

The UI (windows and forms) had a handle to the controller just by its interface. As events occurred on the window, the window class would directly route those to equivalent calls through the controller.

The controller knew about the model. In my case I had an Oracle database and an SDE database. Those were wrapped in classes so that I had control of my own implementation and interfaces for those. The controller would make requests to the databases (existing in the data model namespace) and massaged the data to satisfy the view's request.

It was surprisingly easy to implement and make development very clear, clean, and concise.

j0rd4n
A: 

I believe you utilize both the MVC and MVP patterns with Microsoft's Composite Application Block and Smart Client Software Factory. Here's a link to the documentation: link text

Rick
A: 

MVC was originally defined as a modular OOP style for GUI apps. Only later the name was borrowed by a totally different layered style for web apps. If you don't pay attention to 'web MVC', you'll find lots of 'GUI MVC' examples and references.

Javier
+1  A: 

If my reputation was high enough, I would have commented on what Rick posted. But since it isn't here's my own post:

I too like the Head First design patterns book but I think it is a little too broad for the specific subject matter that your interested in.

If you want to learn how the pros implement MVC using C#.NET WinForms, I highly recommend checking out CAB (Composite UI Application block).

http://en.wikipedia.org/wiki/Composite_UI_Application_Block

http://www.microsoft.com/downloads/details.aspx?FamilyId=7B9BA1A7-DD6D-4144-8AC6-DF88223AEE19&displaylang=en

opadilla
+2  A: 

Most GUIs use MVC in some form or another.

There is nothing magic about MVC, in fact, it's really just a way to say keep your model separate from everything else. A view and control are almost always paired because the implementation specifics of a view drive how the controller is built.

Also, everyone who implements MVC seems to have a slightly different idea of what belongs where. It's extremely easy for stuff to slip back and forth between view and controller--and many views are actually made of an entire miniature MVC architecture!

I'm not telling you to ignore MVC or anything, it makes for a pretty good set of guidelines, I'm just telling you not to stress about coming up with an exact set of rules that everyone follows that absolutely defines MVC because you probably won't find one. Everyone bends it a little to fit the rest of their architecture.

Bill K
+1  A: 

MVC pattern can be applied to windows forms also. Check out MVC#. http://www.MVCSharp.org/Using_Winforms_views_engine/Default.aspx

reticent