14

It is almost and instantaneous whenever I talk to developers about Model View Controller (MVC) they say you make a request to a url the server builds a entity (MODEL) and provides you with visual representation of that model.

  • So does this mean MVC is only for the web or have I been meeting people who are just developers who employ MVC for writing web applications?

  • Are there usages for MVC on desktop style applications?

  • I for one am new to paradigm and would like to know of any super-set to MVC

5
  • 1
    did you check Programmers.SE or Stack Overflow tag wikis for 'mvc'?
    – gnat
    Commented Mar 21, 2012 at 9:02
  • 3
    @gnat yes I did Commented Mar 21, 2012 at 9:09
  • 6
    well then you probably already know the answer to your question don't you?
    – gnat
    Commented Mar 21, 2012 at 9:11
  • 4
    @gnat seriously NO, i am totally new to MVC (as stated) and have never used or heard(some ears I got) about MVC being applied to windows applications or used a application that sports a MVC badge on downloads page. Sorry if the question was foolish but for me it does puzzle Commented Mar 21, 2012 at 9:21
  • There are plenty of good resources for learning the history of MVC but I see this misconception a lot, so I wrote a nice summary on my blog blog.kutulu.org/2012/01/mvc-mvp-mvvm-mvpvm-lmnop-wtf.html
    – KutuluMike
    Commented Mar 21, 2012 at 16:58

8 Answers 8

22

MVC is a pattern. Patterns apply across all programming. MVC just happens to work very well in a web context.

As gnat points out just have a look at the mvc tag and you will see multiple examples of it being implemented.

3
  • 5
    This is key. MVC works really well in web applications, and indeed is a large part of the reason why modern MVC-based frameworks (like Rails, Django, and ASP.NET MVC) are so popular. It works in other contexts (like desktop apps) too, but it is harder to keep a clean seperation of view and controller, so variants that remove the view-controller seperation like Model-delegator (used by Swing) or change where the split occurs like Model-View-ViewModel (used mostly by .Net WPF apps) are more common in Desktop Applications. Commented Mar 21, 2012 at 15:46
  • If you look at the original Smalltalk description of what a controller does -- translate user input into messages for the model -- Windows itself is basically one big controller; that's why MVC as a pattern doesn't mesh very well with Windows UI applications. Its used a lot more in UI Frameworks for non-Windows systems.
    – KutuluMike
    Commented Mar 25, 2012 at 3:38
  • @MichaelEdenfield Not really; you can do MVC and WinForms together, although MVP is more popular there, but MVP is a variant of MVC anyway.
    – Andy
    Commented Nov 8, 2014 at 17:49
45

Considering that MVC is from 1977, and the web was only invented in 1991, it should be pretty obvious that MVC is not only for the web.

7
  • 30
    This is a nice start of answer, but has a bitter taste in mouth.
    – Nicolas C.
    Commented Mar 21, 2012 at 12:06
  • 2
    Correct and snarky. Great stuff! Commented Mar 22, 2012 at 0:22
  • 1
    "In 1982 the Internet Protocol Suite (TCP/IP) was standardized and the concept of a world-wide network of fully interconnected TCP/IP networks called the Internet was introduced." wiki. If you mean netscape, then ok... but "the web" existed before that.
    – jmq
    Commented Mar 22, 2012 at 4:24
  • 4
    @jmquigley "the Internet" and "the Web" are two very different things.
    – Eric King
    Commented Mar 22, 2012 at 14:53
  • 1
    @jmq 1977 though is STILL before 1982, and as someone else pointed out Web != Internet. The web really DIDN'T exist before 1991.
    – Andy
    Commented Nov 8, 2014 at 17:47
9

No, development for OS X and iOS uses Model View Controller pattern.

1
  • 2
    Finally, an answer to the first and second points without the commentary.
    – JeffO
    Commented Mar 21, 2012 at 13:10
8

Ask the question in a Microsoft environment and many people will assume you mean Asp.Net MVC which is an MVC implementation specifically for the web.

Unfortunately there are many people who do not realise that this is an implementation of the MVC pattern and think they are interchangeable terms, which leads to an assumption of "web only".

4
  • 3
    +1 this is the problem with naming a platform after a methodology. When people are introduced to the platform first they fail to see the distinction.
    – MattDavey
    Commented Mar 21, 2012 at 10:35
  • @Ozz this did explain why other developers always use to say about web when MVC is the topic Commented Mar 21, 2012 at 10:42
  • 1
    Please stop painting Microsoft developers as stupid, thanks.
    – Andy
    Commented Nov 8, 2014 at 17:49
  • @Andy - that wasn't MS developer bashing, I'm an Asp.Net MVC developer myself, and I stand by original answer. I didn't say "all" people, or "all" .net developers, just an observation of an assumption or mistake that I have seen many people make. Thanks.
    – ozz
    Commented Nov 13, 2014 at 10:42
2

At least as far as I know, the first implementation of MVC was in Smalltalk. It was definitely present in Smalltalk-80. Though I don't have any documentation handy to prove it, I believe it (or something quite similar anyway) had been in Smalltalk for a few years by then.

Most OO GUI frameworks have included at least some variant of MVC. I'm not sure, however, exactly what "superset" would mean in this case. It's a little hard to say whether any given variant is a superset, subset, or peer of MVC, but I'd tend to consider most of them peers.

In any case, many (most?) of these have been used for desktop development, not web development. Thanks to some old AT&T patents, most windowing systems require programs to be able to re-generate views on demand. This (almost) forces at least some degree of separation between code that maintains the current state (the model) and code that displays that state (the view). That still leaves a lot of room for variation in 1) the degree to which the controller functionality is isolated, and 2) the exact details of where to draw the lines between each of the major pieces.

1

No, it applies even for standalone applications. Example Java Swing follows MVC.

1
  • 1
    Why the downvote the let person live! Commented Mar 22, 2012 at 8:44
1

So there is a lot of different design patterns in this area.

  • Model View Presenter (mvp)
  • Model View View Presenter (mvvp)
  • Model View Controller
  • Model 2

and so on. Over the years these have been intertwined, mashed together, changed and applied in a wide variety of contexts. The important bit here, is that the MVC design pattern from 1977 has changed quite a lot, and is no longer the design pattern used by serverside web frameworks. As an example in the original smalltalk implementation the Model would observe the view for changes, which is no longer the case as the serverside simply can't observe html elements in the users browser. Instead if the view changes, the view will send a request to the controller which will then update the view. Again the original MVC implementation is not followed, as an update to the model would imply that all views dependent on the model would be updated.

The modern web frameworks follows a simple three tier architecture also known as a Model 2 architecture.

There are of course examples of real MVC architectures on the web, but these are often client side only, connected to a server which follows the Model 2 architecture, as the views are xml and json, and not observed for changes. Examples of client side pure mvc architectures are Sencha Touch and Sproutcore.

If you have MVC in the browser, mvc like on the server, and mvc like as the data layer, you have a hierarchial mvc implementation.

Note. I've only talked about web frameworks, other implementations of MVC such as java swing and Flex has other implementation differences.

2
  • Certainly doesn't make sense why people down vote others, if something is wrong please do tell them & give a chance to correct their view. If they don't have knowledge on the subject a good teacher would direct them to right source not beat him until he learns it right!! Commented Mar 22, 2012 at 16:51
  • the question assumes that mvc and web work well togather and pleads for non web mvc, so when you only give examples of mvc in a web context: -1
    – hildred
    Commented Nov 27, 2013 at 20:17
1

One thing you must know is that there are as many flavours of MVC as there are frameworks that claim to implement MVC.

Most agree on the fact that the Model holds some state and the View renders it. But the Controller has very different roles.

In Smalltalk, where it was first described, the Model is the core of your application, data and business methods. The View is a graphical representation of the state of the application (aka Model), and the Controller manages the user input, mouse and keyboard events. The Controller, for instance, routes keyboard events to the view element that has the focus.

In .jsp pages, the Model is mostly data, the View renders that Model to HTML and the Controller does the routing of the Model to the proper View to render it.

So, to answer your question, while MVC is used both on standalone applications (Java, .Net, Flex) and the web (jsp pages), it is a very different thing. That means the MVC you know is not used in standalone applications.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.