Jump to content

Talk:Model–view–controller

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Mahemoff (talk | contribs) at 11:34, 29 November 2012 (→‎History: Re-discovered by Zend? Really?: new section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The original idea

Not sure if this has been mentioned as yet, but Trygve's original concept had the View being a more transitory construct that would be created from the model and managed by the controller. I dont know of any current "MVC" claiming frameworks that work in this way, the closest I've seen is perhaps the naked objects framework in Java. I'm not saying the modern concepts of MVC are invalid, but I think its worth noting what the original ideas were especially since the article does properly attribute the concept to Trygve. — Preceding unsigned comment added by Greywire (talkcontribs) 05:17, 8 February 2012 (UTC)[reply]

Really think the whole concept has been misused/gone to the dogs by now. Its a completely impractical way of constructing a complex site, though it does give undergrads a place to start (a wrong place, but anything is better than nothing). The years I have spent debugging MVC based systems were money-lucrative but utterly time-wasting. It is not maintainable as an implementation. Keeping it as an abstract, which I think matches what the writer above says, was always the way to go with it (if you needed MVC at all in the first place which I dispute). 118.209.89.119 (talk) 03:56, 7 November 2012 (UTC)[reply]

MVC Non-UI Applications

This entire article ignores applications of MVC to non-UI domains; even goes to so far as to assert that MVC only applies to user interfaces. The Pragmatic Programmer has an excellent discussion of using MVC without a UI. Specifically, the "view" component produces an interpretation of the model. (e.g. generating on-the-fly information from data such as stock volatility from historical price information).

WikiProject iconComputer science Start‑class Mid‑importance
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
MidThis article has been rated as Mid-importance on the project's importance scale.
Things you can help WikiProject Computer science with:


[Edit: It also only focuses on the web part of MVC, ignoring non-web based applications.] — Preceding unsigned comment added by 46.11.122.169 (talk) 12:00, 4 January 2012 (UTC)[reply]

Odin Assemble

The projects looks dead. The website isn't available, and the dev blog found via google has the last entries 2006. —Preceding unsigned comment added by 85.179.23.76 (talk) 20:29, 5 November 2010 (UTC)[reply]

Shouldn't it

Shouldn't it be called model-controller-view?

I don't see why. It is a loop, so no order is more appropriate than any other. MVC has been used for decades now, too late to change. --RBS —Preceding unsigned comment added by Randallbsmith (talkcontribs) 19:47, 28 November 2008 (UTC)[reply]


Perhaps. But this is an article about what it is. Not what it should be (or especially what you think it should be!). 205.200.230.112 (talk) 21:28, 18 May 2010 (UTC)[reply]


I would tend to agree that the term "model-controller-view" would serve well to emphasize the controller as a mediator between the model and the view. It seems plausible to me that the perfect MCV construction would totally isolate the model from the view via the controller. What is the Controller controlling if not access between the model and the view. If I have an editable text field in my view and the user provides some text, that text needs to be potentially validated and then placed into the model. If the model is stored on disk and reloaded the view needs to be repopulated with this same text again via the controller. One of the stated purposes for the Model Controller View (or Model View Controller) architecture is to separate concerns. The model is concerned with persistence to disk and business logic, the controller's concerns would center around validation and mitigating access between views and models, and the view is concerned with presentation of 'controlled' data and collecting inputs. There my 2cents. 132.45.121.6 (talk) 17:24, 25 July 2012 (UTC)[reply]

If the infernally silly idea were to be given a name at all, it should really be M-VC, as it is impossible to separate the View and the Controller in real life (web site forms are a good example, so are exceptions that generate 404s). Which really doesn't leave you with much. 118.209.89.119 (talk) 03:58, 7 November 2012 (UTC)[reply]

Drupal is NOT MVC

http://www.articlesnatch.com/Article/Drupal-And-Object-Oriented-Programming-/332433 "Drupal is split into relatively independent layers the similar to the way MVC apps are split into layers. There is nothing inherently magical or special about MVC - there are plenty of other design patterns that acheive the same benefits." http://drupal.org/node/116677 —Preceding unsigned comment added by 87.211.99.74 (talk) 12:17, 19 January 2010 (UTC)[reply]

Origins of MVC

Many of the changes I am making are to make the article more in line with the concepts back in the 1987 Smalltalk paper. Specifically...

  • The controller is the event processing mechanism. You don't just write event handlers in the View that just immediately call the controller. The controller exists, at least in spirit, with the event handlers.
  • Views and controllers are tightly coupled for a reason. If you have two different views with different buttons, text boxes, etc., they cannot share the same controller. Why? Because they don't have the same events.
  • The model is not just a dumb data storage object. This is where all your business rules live. If you are using the controller to process business rules, than you are not following the pattern correctly. Rather, you are writing in the VB's (crappy) "everything in the form" pattern.
    • You had me until this one. Just because an application relies on MVC does not mean that everything must be shoe-horned into MVC. In order to acheive the level of decoupling that ultimately is the promise of MVC, the model can indeed be "just dumb data", or at least an ephemeral collection of values (values which might be objects upon which method calls can be made -- therefore not "just dumb data"), probably retrieved from a fine-grained service layer, albeit via a coarse-grained "facade" interface (business delegate), that the controller references. Jemptymethod 10:32, 20 August 2007 (UTC)[reply]
Wikipedia is not about "having you" (or not). He is talking about the MVC pattern as described in the smalltalk paper. 217.226.55.80 (talk) —Preceding undated comment added 17:39, 7 January 2011 (UTC).[reply]
Rather, you are writing in the VB's (crappy) "everything in the form" pattern. Well, maybe you're just used to Smalltalk's crappy "no rules in the controller" pattern. ;-) — Preceding unsigned comment added by 159.247.123.7 (talk) 18:22, 13 December 2011 (UTC)[reply]


  • In order to understand the MVC pattern, people need to see how it applies to real frameworks. While you may argue that some technologies (e.g. WinForms) doesn't support the true MVC pattern, it is important that people see it and understand how it differs.

Things that are needed...

  • Each component needs more than just a bullet point. We should use the Xerox and Smalltalk documents to give a more indepth description of each.
  • The openning needs to clearly state that the MVC pattern was specifically designed for graphical user interfaces.
  • We need an entire section on how web applications differ from the GUI applications that MVC was originally designed for. Specifically the bit about how it has two triads, one on the server and one on the browser.


-J. Allen


Re tight coupling: I'd argue that controllers and views are orthogonal rather than tightly coupled. The logic of a domain manipulation is quite different to that of the view. What is to be displayed anyway? A simple boolean success/fail message? A 12 page debugging report? Which bits of data from which bits of the object graph are to be collected for viewing? Are you observing object state or messages passed between objects or both? How is all this data being interpreted into a meaningful human-readable display? This is all view logic which doesn't really belong in a controller layer. The same UI interaction can result in different views - say verbose or shortened versions of a report or different content dependng on admin / ordinary user privileges. Views and controllers can have different rates of change but tight coupling means they are not free to vary independently. Actually tight coupling means they don't exist at all in any meaningful sense. V & C have been merged and instead of MVC you simply have presentation & domain layers.

- Noel Darlow

"Actually tight coupling means they don't exist at all in any meaningful sense. "

You may disagree with it, but that is the one and only definition of MVC as presented in the smalltalk paper. You are free to criticise MVC by pointing that out, but to change its definition is wrong. Grauenwolf 17:19, 29 October 2006 (UTC)[reply]

I'm not sure if I am changing the definition or if we are required to use the original smalltalk definition. Concepts often evolve and improve over time - and it's been a while. In my defence I would cite Martin Fowler in Patterns of Enterprise Architecture who makes the comment that many original smalltalk implementations did not in fact separate V and C. Also, from his web page about gui architectures: "I've lost count of the times I've seen something described as MVC which turned out to be nothing like it".

Noel Darlow

I am pretty sure that the MVC concept is of much wider use than for creating user interfaces. From my personal experience (1978-1991), it can be and was used for creating easily extandable software systems (not just one application as most of the frameworks mentioned suggest). If necessary, the respective references can be provided.

David Rozenberg

I believe that Trygve Reenskaug did not publish his original work just because he understood that the MVC concept is much wider and natural to us (human beings). I would serously question any declarations that started in some blogs that there is no need for this pattern or concept. I also think that the interpretation of it made by some people involved with Smalltalk-80 did not add any good, but confused many software developers.

David Rozenberg —Preceding unsigned comment added by 71.224.122.75 (talk) 16:39, 31 December 2007 (UTC)[reply]

I think that it is wrong to put model-view-controller on the same line as model-view-presenter and others as it is done in the Architectural pattern article. The problem is probably the lack of understanding that MVC as it was invented 30 years ago by Trygve Reenskaug is just a reflection of a much wider pattern on creating the user interfaces. Do not take this as an attempt to diminish the role of the MVC invention. It was the necessary step in our understanding of how software should be designed and implemented. MVC is not just that for guis. It is the intrincinct part of our lives. We cannot communicate with each other without creating or using abstractions (data model), analyzing inputs (from different views produced by our sensors), and reacting on them (controller actions). Our languages are based on the MVC concept (intuitively). It is also bad to think of MVC as the means of creating efficient guis in the OO software. At the same time as MVC was invented for Smalltalk-80 an approach similar to MVC and independently was used for designing and developing frameworks and the presentation layers for non-object oriented software. This work may not be known to the western researchers just because it was done in Russia and the language barrier prevented the information exchange at that time —Preceding unsigned comment added by Drozenbe (talkcontribs) 12:50, 4 October 2009 (UTC)[reply]

Platform Independence

here I'd just like to outline my view of' MVC' with regards to the platform-independance/C++ etc stuff in the article.

My view is that both the Model and Controller are written in a platform-independant language. The Model is tied to the View through a very loose notifier/listener (or 'observer') mechanism. So the Model knows to a certain extent that a View exists, but only very loosely. The Controller however has even less knowledge of a View, and simply implements an interface that allows the model to be changed according to the application logic. So the controller might implement a "Load File" method which the View calls when the user selects "File->Load"... or something along those lines.

So when porting to a new OS, only the View code is rewritten, along with the code to call the appropriate methods on the Controller and to respond to updates from the Model.

Does anybody else have any views on this?

MVC does not make a program language independent. MVC is just a way to model an application, a set of rules how program parts should interact. MVC is language independent in the sense that you can create a MVC application in C++, in Java or Cocoa. But a MVC program written in Java is not easier to port to C++ than another program. The reusable aspect of MVC leis therein that the parts act indepently - parts call each other with messages, they do not have to know each other by name or specific method - and can be replaced or extended.
One single program is too small to take advantage of reusability of MVC. The real benefit comes from a MVC framework, that a single program can use and extend.
I agree with the above comment that the platform independence benefits of MVC are largely imagined, or at least unsubstantiated. In my experience, models are typically tied very closely to a document/persistence framework which impedes reusability in the same way that close ties from a GUI framework impedes reusability of an application's view classes.
Expanding on my earlier comments: MVC does not give you platform independence, but can help make code easier to port from one platform to another. This is particularly true when GUI APIs are the most tightly-coupled of the platform-dependent APIs used by an application. In this case all (?) of the the GUI API calls are confined to a set of view/controller classes. But the point is that you are still dependent on the underlying GUI API.
As currently stated, the benefits of MVC are conflated with the benefits of using a cross-platform language. I think language issues are irrelevant here. It is possible to obtain benefit from MVC using a platform-dependent language. Similarly, using a cross-platform language with MVC does not automatically grant platform-indpendence. For example, an application written in python to the Cocoa bindings (using PyObjC for example) is still platform-dependent even though it is written in cross-platform language. Hence I propose removing the language issues from this discussion.
I have specific disagreements with the current content. For one: "Since the model and controller generally have no knowledge of the view, the programmer is free to implement both in a cross-platform language such as C or C++." The implication here seems to be that view classes necessarily require a language that is not cross-platform. Which is frankly wrong; as noted above, the language is irrelevant here. Platform dependence can arise through the use of platform-specific APIs, not just from choice of language.
Also the statement that "Theoretically, an application written entirely under the Cocoa framework for Macintosh could easily be ported to Windows under the .NET framework, as long as the model/controller is written only in C++." is incorrect. For starters, Cocoa is Objective C, which to my knowledge is not supported under .NET. Secondly, Cocoa explicitly incorporates Model and Controller APIs, which means that the application is coupled to the underlying API in more than just the view classes.
So I agree that there are some benefits to using MVC in cross-platform development, but the current description of these benefits is not accurate. --AlastairR 4 July 2005 01:22 (UTC)


About the Advantages/Disadvantages section: The disadvantages are a bit unclear to me. The second paragraph gives a disadvantage, but it's more a generic disadvantage (don't freeze the ui too soon), and it's resolved by the MVC, as explained as the advantage: A flexible view for a static model. There's also the (not MVC-specific) problem that they're programming without understanding the model. No architecture is going to save you in that area, and it's not a MVC-specific problem.

(Above was unsigned, not written by me, the below is by me). Well I'll give you a pretty big disadvantage straight off. Its almost un-debuggable. As in it makes life very difficult for programmers trying to work changes in a system. Sometimes give-up-impossibly difficult. This is why I avoid it and tell my students to avoid it (and, incidentally, to take the entire GoF book as a purely academic excercise to be digested with a bag of salt). 118.209.89.119 (talk) 04:01, 7 November 2012 (UTC)[reply]

Patterns

I read on another WIKI that the Model-View-Controller is made from three patterns: Composite, Observer and Strategy. Does anyone know if this is correct? - Daniel Lewis

I think it's fair to say that these patterns are useful in creating an MVC architecture, but are not required. In other words it is possible to build an MVC-compliant architecture without using these patterns. --AlastairR 4 July 2005 01:22 (UTC)
I disagree with AlastairR. As stated in the Gang of Four's "Design Patterns - Elements of Reusable Object-Oriented Software" (the bible for design patterns), the main relationships in MVC are given by the Observer, Composite, and Strategy design patterns. 213.93.217.159 14:59, 14 July 2007 (UTC)[reply]

I would say that MVC is decomposable into just two patterns: Observer and Strategy: the View is an Observer on the Model and the Controller is a Strategy for the View. --gschadow 19 Dec 2005

MVC predates the GoF design patterns, so it may be more accurate to say that the Observer and Strategy are based on the MVC design pattern. - J. Allen 20 July 2006

I think MVC is just about two observers but I may be wrong ;] . mooph 07/22/08 —Preceding unsigned comment added by 213.191.111.80 (talk) 07:34, 22 July 2008 (UTC)[reply]

Image

The image http://upload.wikimedia.org/wikipedia/en/1/15/Mvc.gif is not exactly correct, the model doesnt not really update the view, it just publishes the events, the view or the controller takes care of actually updating the view (because its subscribed to the evenmodel of the model) . With the current text associated with the model image one could assume that the model has knowledge of the views, which it has not. Thats why there is such a high level of decoupling.


I'd go further and say that the controller also cannot update the view. What I mean is that the controller may issue an instruction telling the view to update itself but should not pass a model to a view. The view gets its own data: that's what MVC is all about ie finessing the standard presentation/domain separation with a further split in the presentation layer between controller and view.

Shouldn't we therefore say that the point about the Controller is that it can be exchanged. For example, the same view could display the data of an object using a Controller that responds to very few events, but it could be used as an editor using a conroller that converts keystroke events into changes to the model. --gschadow 19 Dec 2005

I've edited the page recently and either I messed up my submission or it's been edited. If there has been some editorial intervention can you mention it here: I don't want to appear to be spamming.


All this talk about "the model must not update the view" or "the controller must not pass the model to the view" is utter rubbish. The MVC design pattern merely identifies the responsibilities of each of the three modules, it does not specify how they are to be implemented, or how each module communicates with another, or how changes in the model make their way to the view. These are all implementation issues, and as such are not cast in stone but are entirely fluid, limited only by the skill of the programmer and the language beng used.

Provided that the implementation contains three distinct modules, each with the relevant responsibilities, then it is MVC, period. The fact that someone else's implementation may be different from yours does not make your implementation right and the other implementation wrong. They may be different, but they are both right.

Tony Marston 10:50, 19 June 2006 (UTC)[reply]

The key point about MVC is that view and controller are separate layers. If the controller were to pass model data to the view you would have to edit the controller every time you change the set of data displayed in view. Quite clearly the controller and view would not be separate and therefore it's not MVC.


Actually both the Controller and the View should have a reference to the model.

The View uses its reference to the model to extract data that is needs to display. The Controller uses its reference to the model to initiate updates based on the events it is processing.

In the Smalltalk implementation, the View is actually in charge of creating a pointer to the controller, telling the controller to point back to it, and registering itself with the model.

In some implentations, the controller actually updates the View using the Model. In others, the View automatically updates itself. An example of the latter is bound controls in ASP.Net. The controller calls the DataBind command on the view, which in turn updates itself using the model.

The only requirement is that the model doesn't know about the view or controller. It may expose generic event hooks, but that's about it. Otherwise the model cannot be used in other MVC triads.


-- J. Allen 20 July 2006

Resolved

What's up with that comment about GOTO's and globals? Who's implementation of MVC is that messed up?

The article only explains the benefits of the Model-View division. Not its extension to model-view-controller.

I've completed the merge from Model view controller triad. Also made some other changes:

  • Added brief intro: is it a design pattern?
  • Created benefits and liabilities section, moved platform independence discussion into subsection there
  • New liability: breaks encapsulation (ref Alan Holub's article)
  • Reorged SmallTalk refs into Implementation section
  • added reference to Buschmann, et al.


True MVC vs. "crippled" MVC on/for the Web

The article is not clear enough about interactions between M, V and C. Their functions are also described somewhat insufficiently. This is probably common for any recent description of the pattern and has resulted in claims that traditional web applications (completely) implement (full) MVC. They can't. For that they would require Server push.

Rich Internet Application and AJAX are changing this picture slightly (the requirement still stands, but if unavailable there are compromises).

--Aleksandar Šušnjar 21:03, 18 January 2006 (UTC)[reply]

The MVC doesnt require server push. The application of the Observer pattern to allow the model to send notifcations to a view is a common and elegant enhancement to the MVC. It is not a core part of the core MVC pattern.

You are talking about an active model as described in the Smalltalk-80 description. Yes, this would require server push for a web application which is not possible (but may badly be simulated with for instance an AJAX timer on the client side polling for state change on the server). However, passive models are possible in web applications. 81.235.236.122 (talk) 17:09, 24 March 2008 (UTC)[reply]

---

Actually messages from the Model to the View are part of the original Smalltalk MVC design. The idea was that multiple MVC triads could share the same instance of a model object. When the model is updated by any triad, it sends a "changed:" message to all views registered with it. Note that with this design the model has no concept of a "View" aside from the fact that it listens to events the model sends.

Sounds like the observer pattern to me.

- J. Allen 20, July 2006

---

The article really needs a kind of clarification. Separation of Model and View is not sufficient for a library or Framework to implement MVC. Every library or framework for interactive applications presents (View) data (Model) to the user and handles user interactions (Controller), but that does not mean that every such library or framework implements MVC.

For instance: "In the case of WinForms, the View and Controller are compiled into the same class.", means that WinForms are not MVC implementation (view and controller are not separated). And next: "The duties of the controller are split between three places."(!)... only justifies this view (the controller is not centralized). The same applies to MFC and many other listings.

The need for another kind of clarification is rather tricky. A part, that is by itself MVC does not automatically make the whole MVC. Here is the example: XForms document is Model (instance document in the head section) - View (layout in the body section) - Controller (DOM Event model). But that does not mean, that any web application which uses XForms as View implements MVC. Such clarification is needed to avoid misconceptions like Model (Frame level) and Model (Control level) in Swing section.

The article should focus more on MVC itself, its parts, their responsibilities, and their relationship. The list of libraries (frameworks) which does (not) implement MVC is unnecessary and confusing.

--Maroš Ivančo 16:40, 10 February 2007 (UTC)[reply]

MVC graphic

The MVC graphic used on the page is confusing. I think it should have the dashed lines removed (the observer paradigm has its own page) and the direction of the arrows should be explained. -- cmh 04:55, 13 May 2006 (UTC)[reply]

It also uses transparency which breaks where alpha channels are not available (such as printing).

this image http://de.wikipedia.org/w/index.php?title=Bild:ModelViewControllerDiagram.svg should be used, because it is vector graphics
transparency should be used, where should it break exactly? -- someone else —Preceding unsigned comment added by 78.53.194.237 (talk) 17:58, 24 June 2008 (UTC)[reply]
The image file has this talk, which I copy here to centralise the discussion:
The diagram here is wrong. The whole point of MVC is to prevent the model knowing about/interacting directly with the model, and vice versa. Thus the solid lines between the view and model are incorrect - everything should go through the controller. In addition, the view can indirectly observe the model (so a dashed line would be allowable). 60.229.72.31 (talk) 11:43, 24 October 2008 (UTC)[reply]
Copied -DePiep (talk) 16:39, 27 April 2009 (UTC)[reply]

Advantages and disadvantages

The only advantage listed is that MVC is more robust with respect to view instability than is having NO architectural separation of UI and business logic. And no disadvantages are listed, despite the section's name -- probably because nothing besides MVC is even mentioned. This section sorely needs some meat, I wish I had the knowledge to contribute it.




I Agreed, most likely that this wiki is controlled by fans.

There are (not exclusive) three "kind" of pattern idelogy, 3-tier, MVC and 3-layer and since different projects can have different trouble/needs, you must choice the best kind of model, not lets the model choose the workflow for you.

This models have their advantage and disadvantage, there was not a pattern that work for everything and MVC is not the exception. The real trouble with MVC is the lack of clarity with the concept, for example in some projects Model and Controller can be the same or view can be a blurry part of the model.

List of Frameworks

I'd like to suggest that the list of frameworks is not good content for this article, and that it would be more appropriate to link only to those frameworks which already merit their own article on Wikipedia. For the rest, a pointer to an external listing of software might be better. Szarka 15:02, 16 May 2006 (UTC)[reply]

Also, some of these aren't even MVC. I'm from a php background and, in this language at least, MVC is very poorly understood. People seem to get the presentation/domain split reasonably well but stop there. That's not MVC though. MVC goes further, breaking the presentation layer down into separate View & Controller layers.

Removed the paragraph about some PHP frameworks not being MVC -- better to remove the non-MVC ones from the list than to write a bad paragraph about it.

I agree on szarka´s note´s, today while i surfed the internet on freshmeat.net there was a new software project announced smutty [1] maybe someone of the moderators can add that to the article


--I think it is important to note how, or even if, the msjor frameworks support MVC. How is especially importent to me because the original MVC pattern was specific to a SmallTalk GUI toolkit. From what I've read, you literally could not violate the MVC pattern.

As for "separate View & Controller layers", that is not entirely correct. In the original MVC pattern they were implmented as seperate objects, but they were very tightly coupled. Each controller worked with one and only one view. Grauenwolf 17:15, 29 October 2006 (UTC)[reply]

View vs Controller in web applications

The part in bold does not make sense to me as this is invoking change by calling on the model. When the data is gathered it is outputted into HTML which is then rendered by the browser. Would this not be considered the job of the controller?

"View: Renders the model into a form suitable for interaction, typically a user interface element. MVC is often seen in web applications, where the view is the HTML page and the code which gathers dynamic data for the page. "

"Controller: Responds to events, typically user actions, and invokes changes on the model and perhaps the view."

Wikvin 18:25, 13 July 2006 (UTC)[reply]

Views are read-only. They would not manipulate model state. As you say, that's the job of the controller.

-Noel Darlow

I think this is a huge area of confusion for many people. I would suggest including some specific comparisons between m/v/c, as Noel did in his response, which was very helpful. the current comparison/definition section is confusing, especially with the high repitition of 'domain' without much explanation. it makes me think that 'domain' is some buzzword i should know about if I am truly understanding the article. I am scared to edit the page myself, but I hope this reaction helps! -red daly (atgmail.com if need be)

The long list of frameworks for web applications poses the question - Why do we need that many of them? Don't they provide the help for constructing the same type of the application? How they are different? What are the advantages of using one framework comparing to others? Which one is the champion?

David Rozenberg

David Rozenberg question is what made me read this far. With any framework, "the devil's in the details" which is something you don't find out without significant study AND experience. It takes so long to plumb the depths of the frameworks available that no-one can learn the details of them all. If anyone knows where to find people who want to discuss these differences knowledgeably and politely without getting zealous about any one solution, let me know. --GlenPeterson 17:27, 8 November 2007 (UTC)[reply]

AVC, the Application View Controller an alternative to MVC

Recently (Jan 2007), I developed a python module that makes the job of MVC in a fully automatic and transparent way. The connections between the controlled variables and the widgets are autogenerated by looking for matching names between widget names and variable names.

The application is completely unaware of the presence of the connected variables, it reads and writes them as normal variables. Only if the application requires to be immediately notified when a connected variable changes value, a notify handler must be added to the application.

For more info see the AVC home page [2].

Fabrizio Pollastri --Pollastri 09:09, 2 February 2007 (UTC)[reply]

Regarding .Net

ASP.NET does not strictly require a model. The developer has the option to create a model class, but may choose to forget it and have the event handlers in the controller perform any calculations and data persistence. That said, using a model to encapsulate business rules and database access is both possible and preferable.

To me this sounds inaccurate. First no language enforces the use of models, MVC frameworks usually do, therefore comparing .Net Runtimes versus Ruby on Rails seems like comparing Apples to oranges. Secondly .Net does support a model, it's called DataSets. To create custom models you create a Typed Dataset. It's actually done very well in .Net and is fully persisted and serializable.

If nobody has a compelling reason against this, then I will correct this section. —The preceding unsigned comment was added by Kibbled bits (talkcontribs).


I don't understand the implementation emphasis in the .net entries. MVC is a *logical* solution to a problem which the developer has to decide is correct or not. The implementation in various language can be demonstrated given an example, but to expect a platform to enforce design consideration on the developer is wishful. Harecourt 20:58, 8 May 2007 (UTC)[reply]

Can anyone make model part of the pattern description more understandable?

I can't! But I can tell you why it is hard to understand ... maybe that will help someone re-write it.

It says that the model layer shouldn't be confused with the domain layer, but doesn't explain what the domain layer is. It would be helpful if someone could tell us what the domain layer is (I have had a look but can't find anything on it). The next sentence talks about domain logic, saying that domain logic adds meaning to raw data, and then gives an example OK, but given that it is domain logic, and the domain layer shouldn't be confused with the model, is this something that the model should or shouldn't do? I would guess not. But to me it sounds like something the model should do, otherwise why give an example in this section? Confused? I am!

Leave this to the programmers. This article is already one ugly soup. Don't make it worse.

OK - hope that helps someone make this section less confusing. I would love to have a rock steady definition, in a topic where understanding the boundaries for these three terms is crucial + very hard. :-) Michaelmcandrew 23:24, 9 July 2007 (UTC)[reply]


I agree the pattern description needs rewriting to make it more understandable. It also needs to explain how the Observer, Composite and Strategic Patterns are incorporated in the MVC-pattern. (As stated in the Gang of Four's "Design Patterns - Elements of Reusable Object-Oriented Software").
A nice real world example can be found here http://csis.pace.edu/~bergin/mvc/mvcgui.html 213.93.217.159 16:12, 14 July 2007 (UTC)[reply]

-- It is very confusing. The model is the domain layer (the term comes from "domain model"). Some people seem to think of data access is part of the model too but everyone will agree that this is where domain logic happens. —Preceding unsigned comment added by 212.159.44.241 (talk) 18:10, August 30, 2007 (UTC)

Perl MVC -- Maypole? Catalyst needs editing.

Howdy. I'm not an expert on whether Maypole is a popular enough distribution to include in the list of Perl MVC suites, but am enough of an advocate to think that the languge needs as wide an array of distribution options as other languages in the list (PHP, Python and even -Ruby- have multiples).

Additionally, what's written there for Catalyst is mighty Advert. I would hope at the least the package mentions would point to CPAN for reference. As an example: The difference between DBIx::Class and Class::DBI is not immediately apparent even to those familiar with the language (or at least myself) and reference would clarify.Ogre lawless 07:47, 25 July 2007 (UTC)[reply]

MVC and MVP?

How is this different than MVP? Why isn't there an article on MVP (Model View Presenter) on Wikipedia? 129.120.86.169 22:48, 23 October 2007 (UTC)[reply]

My guess is it's akin to what MS did with CUA - rechristened their version CUI.

MVC2

The DragonPHP uses MVC2, but what is that? They just link (back) to wikipedia (to this article). And regarding PHP I don't think that there's a need for versioning. AFAIK, Java has MVC1 and MVC2 due to the JSP and Servlet difference. PAStheLoD (talk) 21:22, 14 February 2008 (UTC)[reply]

Maybe this article should just admit ...

The article (and much of this talk) follows the Smalltalk idea of MVC, notably that the View is read-only and the Controller accepts the user inputs. There is a newer pattern, where the View handles both input and output and the Controller primarily exists to connect View and Model. One very clear image and description of that idea is at [Apple's Objective-C tutorial]. There are some spots in the main page citing MVC use of systems that follow the newer pattern (e.g., Swing and EE), yet describing them as if they follow the Smalltalk definition, which they do not.

I'm not attempting to argue the relative merits of the two models, here, but this disjunction has become so large, yet so unacknowledged, in the industry as a whole that I think maybe the Wikipedia article really ought to describe both (or at least, to admit to their dual existence). Jackrepenning (talk) 17:56, 10 March 2008 (UTC)[reply]

Maybe you should just admit... This discussion of yours is essentially semantics and no more. It's obvious you're not a programmer. As the next to last commenter on this page suggests, perhaps it's best if laypersons stay away.

Joomla as a MVC application

I recently added Joomla version 1.5 to the list under PHP, but the change was undone by Yarzar110. So before I readded it I wanted to discuss it. From what I have messed with the source of Joomla 1.5 it follows the model discribed in the article. Can somebody confirm or deny this? MarkRomero (talk) 23:14, 26 April 2008 (UTC)[reply]

It might be, that Joomla is a MVC application. But so are thousands of applications. What is listed here, are MVC libraries/frameworks you can build with. However Joomla probably contains such a library as a fundamental component. From my point of view the interesting question is, if you could use that component independent of the whole joomla product and how this component is called in special. --79.196.208.123 (talk) 11:21, 27 April 2008 (UTC)[reply]

The reason why I added it was because phpXCore was on the list and its description is a content management framework. As far as I know the library could be used independently, but since it is relatively new there have not been any derivative works based on the library. MarkRomero (talk) 13:50, 27 April 2008 (UTC)[reply]

Almost all apps today are MVC. Adding Joomla to a list constitutes advertising in that context. —Preceding unsigned comment added by 86.221.27.112 (talk) 11:21, 28 December 2008 (UTC)[reply]

Problems with the article?

See this article:

I don't think the wikipedia page is a particularly strong reference for learnign anything much about this topic, since it focuses on examples (many of which, arguably, aren't MVC at all) and stumbles on the various ways to define MVC. My personal feeling is that if you want to get an understanding of the complexities and layers behind the terminology, the ModelViewController page at c2.com and following the links from there is a good motivator. Note that many of the people writing on those latter pages were actively involved in the historical usage and development of the pattern, or worked with people who were directly involved.

Then a good idea would be to let them write this article. Laypersons should not approach this article as has evidently happened.

Can anyone see the issues? - Tbsdy lives (formerly Ta bu shi da yu) talk 21:20, 2 December 2008 (UTC)[reply]

This Article is Terrible

This has got to be one of the worst technology articles on Wikipedia. Seems to have been written by a bunch of computer science people who don't have any real-world, hands-on coding. A piece of advice to all would-be editors of this article: If you are not a paid full-time program in at least two languages and have not actually coded within a MVC framework for at least a year, DON'T ILLUSTRATE YOUR IGNORANCE BY TOUCHING THIS ARTICLE!!! —Preceding unsigned comment added by 24.227.114.197 (talk) 22:11, 18 December 2008 (UTC)[reply]

Sounds good. I would point out one thing. This article abuses the word 'pattern' when referring to MVC. AFAIK this is generally unheard of. And the original article referenced in this 'article' (by Steve Burbeck) doesn't use the word 'pattern' a single time.

Burbeck (and the rest of us) refer to MVC as a paradigm. But see above.

PS. As someone often working with document development and having innumerable colleagues across the globe I know it's common knowledge that it takes far more work to remedy a bad article than to write one correctly from scratch. Far more work and a lot more time. So those of you referred to by the above commenter: please feel singled out. For you are perhaps the chief cause Wikipedia is not of generally acceptable quality in academic circles today. Your cooperation is appreciated.--unsigned

If the article is so bad, then why not help make it better? Obviously if the people who are knowledgeable in the area don't step up and contribute, then the people who don't have such a strong understanding of the subject will end up being the ones writing the article. That said, however, I don't actually believe this is the case here. Other than squabbling over petty semantics, neither of you have listed any specific problems with the article, nor offered any suggestions on how to improve it. So perhaps neither of you are the programming or MVC experts you purport to be and more likely whiny teenagers with over-inflated egos. And don't criticize other people's contributions when you haven't even picked up basic Wikipedia etiquette, such as signing your talk comments.--Subversive Sound (talk) 02:39, 12 February 2010 (UTC)[reply]

Needs rewrite?

The lower sections are in particular need. I tried fixing but may have worsened them—I think an article rewrite is warranted.

The organization is poor. The explanations contain jargon (which frightens the unfamiliar) and useless padding (which annoys the familiar). I doubt Java Swing is a good example because A) it requires explanation of Java-specific jargon and B) its implementation of MVC is obscured to those not familiar with it. Although I'm not familiar with it, I think the Servlet–JSP–XHTML example is good in concept—but needs serious improvement. Also, "Implementations of MVC as web-based frameworks" should be merged if not removed.

I think the most severe issue is unwarranted interchange of semi-synonymous/not synonymous terms. Maybe this article can make it through. Any other thoughts?  dmyersturnbull  talk 08:17, 28 January 2009 (UTC)[reply]

new diagram

Another version of the diagram here: commons:file:MVC.png

Wooptoo (talk) 17:49, 30 May 2009 (UTC)[reply]

needs 3 sections

One for Model, One for View, and one for Controller. Needs 1 paragraph on each part. This article needs work. —Preceding unsigned comment added by 71.131.1.140 (talk) 18:42, 15 August 2009 (UTC)[reply]

web cycle + mvc + simple example

Is it correct? (using a pseudo code)

// page.html?value=something 
// controller
if value="something" then 
// model
    object.information=value
    object.save
    message="saved"
 else
    // model
    object.information="empty"
    message=""
 end if
// view
render(<html><body><form><input name="value" type="text" value={value} /> {message}<input type=submit /></form></body></html>)


--200.83.2.4 (talk) 19:24, 22 October 2009 (UTC)--200.83.2.4 (talk) 19:24, 22 October 2009 (UTC)[reply]

No tie-together?

Model–View–Controller presents the Model, the View and the Controller, what they approximately do, but then? What ties them together? Is it just a modular approach in program development, such as we have separate models, views and controller testing scripts, or does it build up separate processes for the respective modules that are then communicating by a FIFO, such as termios, a HTTP-protocol, a pipe or a socket? What protocol is generally used in real life? If so the modules have to speak a language comprehended by sender and receiver module, such as (mentioned) XML, HTML, Volapük, whatever. What language is generally used in real life? Do those comm protocols/languages go under a certain term when adhering to the MVC pattern? In a way the MVC pattern is a philosophy of program design, and the philosophy of program design must provide a complete terminology for all topics that arise under the program development, improvement, and maintenance. ... said: Rursus (mbork³) 09:47, 15 December 2009 (UTC)[reply]

Java Platform (the 'example'): Terrible article, indeed

This subsection (under Selected frameworks) is pretty bad...

Without unrelated information (knowing the Java platform), it is almost unreadable.

Quoting this section (the 2nd MVC list, as if the first wasn't bad enough), here's what I mean:

(Model) The model is commonly represented by entity beans, although the model can be created by a servlet using a business object framework such as Spring.
Not knowing what an entity bean, a servlet, or spring is, this sentence contributes no information.
(View) The view in a Java EE application may be represented by a JavaServer Page, which may be currently implemented using JavaServer Faces Technology (JSF). Alternatively, the code to generate the view may be part of a servlet.
Translated, this to me means:
The view in Blah may be represented by a Blah, which may be currently implemented using Blah. Alternatively, the code to generate the view may be part of the Blah
(Controller) The controller in a Java EE application may be represented by a servlet, which may be currently implemented using JavaServer Faces (JSF).
So what?

... All unhelpful JSP-specific jargon. And even if I had a better idea of what it meant, what is written in that section does nothing to help define MVC. If I already knew the details about the platform, this section would still contribute nothing and would be a waste of time to read, I think.

The problem is made worse because it seems to serve as the primary example.

Maybe this article would be helped with some more general (maybe even user-written) pseudo-code.

Shame that it's such an important concept and that Wikipedia's rendering is so deficient.

121.210.170.141 (talk) 15:53, 7 January 2010 (UTC)[reply]

Terminology : View/Viewport

Even in the abstract, the words View and Viewport become hazy. I think that if the word viewport is going to be used, it should either be explicitly noted that it is a synonym with "View" (in which case it ought to be eliminated), or the difference must be noted!

--Limited Atonement (talk) 17:15, 31 January 2011 (UTC)[reply]

disputed-section: Java Example wrong?

From this article's current version:

  • the JSPs (i.e. the View) do not have to communicate with the model because the Servlet (i.e. the Controller) provides them with the information—they can concentrate on creating output.

This statement is odd: following the initial definition of MVC laid out in the overview section of this article, in a typical implementation of MVC, the View does access the Model. It more seems this is an example of a three-tier architecture. --Abdull (talk) 12:45, 27 June 2011 (UTC)[reply]

I've added an appropriate source and removed the tag. aprock (talk) 05:04, 1 April 2012 (UTC)[reply]

New Image(s) Requested

I was reading today on Multitier architecture and saw the picture on that page illustrating an example of the steps used to process an user request using the principles laid out in that article. I would LOVE to see picture(s!) like that on this page. I first came to this page (MVC) to learn (about) MVC, but wound up being very confused for a week or two. Even now, I've rather given up thinking, "Well, this is something about a SmallTalk paper that I've never read, so I'm never going to get it fully." I think that new pictures in the fashion stated above would be tremendously helpful.

--Limited Atonement (talk) 13:03, 2 July 2011 (UTC)[reply]

A MORE DESCRIPTIVE IMAGE PLEASE

Hi, I think this (http://ruby.railstutorial.org/images/figures/mvc_schematic.png) is a much more descriptive image of what MVC is and how it works than the current one.

It belongs to a free online book about Ruby On Rails written by Michael Hartl found here (http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec:mvc)

I don't know if you can use that picture in wikipedia, but it wouldn't be very dificult to replicate that image from scratch using tools like Microsoft Paint. I don't know how to even upload an image, so if anybody has some time please replicate that image and upload it to the article because a picture worth a thousand words :) — Preceding unsigned comment added by BlueSky23 (talkcontribs) 15:05, 9 October 2011 (UTC)[reply]

jQuery?

why is jQuery used as an example? can be done correctly in current javascript. since javascript is a known standard, using it as a basis seems common sense right. jQuery exists primarily because of the past nature of immature and conflicting implementations. seems to me that, with HTML5 coming into being, there should be no enforced reliance on jQuery, esp for purposes of illustration, when correct javascript will do.

Dancer/Sinatra - MVC?

These micro-frameworks demonstrate separation of concerns but I don't think they qualify as examples of MVC/Model 2. — Preceding unsigned comment added by 193.1.228.155 (talk) 10:03, 1 December 2011 (UTC)[reply]

Express JS

Is Express (the Node.js framework) really MVC? The words "mvc", "model" and "controller" don't appear anywhere in its documentation. Its official summary on Github is "Sinatra inspired web development framework for node.js" – and Sinatra definitely isn't MVC. Can anyone verify this? Denbosch (talk) 11:48, 15 February 2012 (UTC)[reply]

Huh?

Sorry, but I still don't really get it. Can we please explain this in a way that someone, who doesn't already know what it is, can understand it? --Uncle Ed (talk) 18:01, 6 June 2012 (UTC)[reply]

  • I don't mean to edit war, but I've been delivering software for 25 years and it's how I make my money. Please explain this to me and to our other readers in a way that makes sense.
    1. What is the "model"? Is that where the business rules and data live?
    2. What does the controller do, then? Is that what tells the model to change state? In response to what? User input, maybe?
    3. What is the view? When, how and why does the model give it information? Does the controller function to separate the model from the view? Does the controller ask the model for info, or does the model tell the controller that its state has changed and then notify the controller, which then in turn tells the view to change?
  • Without answers to these questions, a longer article is worse than a stub. --Uncle Ed (talk) 01:32, 7 June 2012 (UTC)[reply]


MVC is a design pattern, and as such it has to be adapted to the system at hand. So the essence of the pattern does not lie in details of how one component manages to communicate with another, but in the fact that there are separate components and they communicate in certain loosely specified ways. That said,
  • the model: yes, it has data. Always. It might have business rules, or those might instead be captured by the controller, in terms of the control operations it supports.
  • the controller: it mediates input. Simple example: You have text in the edit box and want to copy it. To do that you press the mouse button and move it around until have text highlighted. Then you release the button, hold Control and tap C. That whole sequence of actions produces one command: "Put this in the clipboard." Something has to do that translation.
  • the view: It's the part that generates output representing the data.
  • How does the model give it information? By whatever means are convenient for the system. Procedure calls, requests over a network, message queuing, etc. Those details are not essential.
  • Does the controller ask the model for info? It might. That's what happens in Java EE. In Smalltalk, every view registers with the model to be notified, and then requests information directly from the model.
But how does it help in the end for me to answer these questions? I can't be cited as a source. That's why I've focused on carefully paraphrasing people with some authority. This isn't Wikiquote, after all. 24.22.217.162 (talk) 04:28, 7 June 2012 (UTC)[reply]
Thanks for this edit. What you wrote was clearer and more accurate than my attempt. --Uncle Ed (talk) 13:45, 8 June 2012 (UTC)[reply]

Component interactions: Huh?

So now I find myself in Ed's position with regard to recent edits. The "component interactions" section was created to describe communications between the MVC components, working closely from what published sources say on the subject. The recent changes to the section have added descriptions of each component per se. The new text uses vague or metaphorical terms like "glue", "things", "operation", "something", all cited to a blog posting. I don't mean to own the article, but if someone wants to elaborate on the definitions of the components, then those definitions belong outside the "interactions" section, and they should be reliably sourced, and they should be in specific language. 24.22.217.162 (talk) 23:46, 18 July 2012 (UTC)[reply]

Diagram?

There was an interaction diagram a few weeks ago, but has been removed as part of the cleanup. Was the diagram wrong? Jay (talk) 10:31, 24 July 2012 (UTC)[reply]


MVC is what ?

The introduction is wrong to me : "Model–View–Controller (MVC) is a type of computer user interface ". MVC is definitely not a type of UI. But I can't find a term or expression that could classified MVC. (it's not a design pattern, more a architectural pattern ...) Kyro (talk) 19:31, 20 August 2012 (UTC) edit:Btw the article became really shitty after the lasts modifications. Kyro (talk) 20:21, 20 August 2012 (UTC)[reply]

Changed it to a pattern. The statement "... (MVC) is a type of computer user interface" is, as Kyro states, definitely wrong. The finer points of "design pattern" can be discussed but at least it is in the ballpark.MartinRinehart (talk) 18:19, 6 September 2012 (UTC)[reply]

Forgive the impudence, but you could just call it "A load of pseudo-academic rubbish designed to sell books and create ridiculously overcomplicated and inefficient software." Since thats what it is. 118.209.89.119 (talk) 04:03, 7 November 2012 (UTC)[reply]

History: Re-discovered by Zend? Really?

The history section seems completely wrong. How could MVC be re-discovered via Zend Corp, when MVC papers were published by the author in the late 1970s?! From the author's own homepage: http://heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html

MVC is mentioned in the Design Patterns text, published 1995, and many other sources prior to that. I don't have the books referenced here, but it seems like a ridiculous statement to make. Perhaps the only truth in it is if MVC was locked under NDA, but if so, it must have only been for a year or two. Not two decades!