Hey Daniweb! What's a good site, or maybe someone could write up a quick-and-dirty example of a desktop app showing how to use the Model View Controller pattern?
I'm no slouch at google-fu and found this lovely example through Wikipedia: http://www.songho.ca/opengl/gl_mvc.html
which I'll look at after class tonight. I'd still like any examples you could provide.
Thanks, Daniweb!

Dani AI

Generated

already found an OpenGL-focused MVC writeup and pointed to ASP.NET MVC (which targets web). For desktop work the same "MVC" label is implemented differently by each toolkit: Smalltalk-style MVC evolved into the model/view approach, MVP and MVVM variants used by modern UI frameworks. (en.wikipedia.org)

Practical starting points by platform:

  • Qt (C++ / PyQt / PySide): use the official Model/View Programming guide — it explains QAbstractItemModel, views, delegates and proxy models and includes copy-pasteable examples for lists, tables and trees. This is the most production-ready MVC-like story for Qt-based desktop apps. Qt Model/View Programming. (doc.qt.io)

  • Java Swing and .NET: Swing uses a separable model architecture where the view and controller are often bundled by the Look-and-Feel; the Oracle Swing tutorial (Converter example) shows how models fire events and update views. For Windows desktop, WPF favors MVVM (a close relative of MVC) — data binding + ViewModels is the idiomatic route. How to Use Models (Swing), Patterns — WPF & MVVM. (docs.oracle.com)

OpenGL-specific note: many OpenGL desktop demos wrap rendering into an MVC-like split so the scene/state is the Model, GL context/commands live in the View, and input/interaction lives in Controllers — course and teaching examples show this pattern in practice. Hello, OpenGL — recast into an MVC framework. (people.eecs.ku.edu)

Example skeleton (pseudocode):

class Model { sceneData; notifyObservers(); }
class View  { setupGL(); render(const Model&); }
class Controller { handleInput(event) { model.update(...); } }

Summary: pick the pattern the UI framework expects (Qt → model/view, Swing → separable-model, WPF → MVVM). For OpenGL rendering, keep GL-specific setup in the View and the scene/state in the Model so rendering code remains testable and portable.

http://www.asp.net/mvc/tutorials - That has some tutorials for the different versions of MVC. Haven't had a proper look at them yet though. There was one site that I found that should be somewhere in my bookmarks..I'm in the same boat as you - I'm just starting MVC.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.