I've heard the term MVC (Model View Controller) tossed about with a ton of Buzz lately, but what really is it?

- 10,517
- 12
- 52
- 63

- 29,502
- 35
- 121
- 166
-
1I'm voting to close this question as off-topic because it's an abstract/theoretical question about programming, which is more the domain of Programmers.SE than Stack Overflow, but even over there it's considered too broad: [the equivalent question on their site](http://programmers.stackexchange.com/questions/127624/what-is-mvc-really) has been closed, though readers may still find the answers useful. – Jeremy May 14 '15 at 01:05
13 Answers
You might want to take a look at what Martin Fowler has to say about MVC, MVP and UI architectures in general at Martin Fowlers site.

- 6,367
- 1
- 24
- 35
I like this article by Martin Fowler. You'll see that MVC is actually more or less dead, strictly speaking, in its original domain of rich UI programming. The distinction between View and Controller doesn't apply to most modern UI toolkits.
The term seems to have found new life in web programming circles recently. I'm not sure whether that's truly MVC though, or just re-using the name for some closely related but subtly different ideas.

- 7,312
- 6
- 31
- 31
MVC is a design pattern originally pioneered in the olden days of smalltalk.
The concept was that a model would represent your application state and logic, and controllers would handle IO between "Views".
A View was a representation of the state in the model. For example, your model may be a spreadsheet document, and you may have a view that represents it as a spreadsheet and a view that represents it as a pivot table.
Modern MVC has been polluted with fake MVC web junk, so I'll let others answer that.

- 172,459
- 74
- 246
- 311
-
7You make the statement "Modern MVC has been polluted with fake MVC web junk" and then avoid addressing it, deferring to "others" that will answer that. Why do you feel this way and why don't *you* elucidate for us? – Jason Bunting Sep 24 '08 at 21:03
-
1I deferred to others because I knew that in 10 minutes there would 8 answers equating MVC to Rails :) – FlySwat Sep 24 '08 at 21:16
-
Ah, I see...you are saying Rails is *not* really MVC? I don't know much about Rails, so I can't address that myself... – Jason Bunting Sep 24 '08 at 21:22
-
2Rails, and most other web MVC frameworks move business logic to the controller (and sometimes the view!) and usually use the model as a dumb datastore. In a purist viewpoint, this is not MVC...however it works, Stackoverflow is using ASP.NET MVC...same idea there. – FlySwat Sep 24 '08 at 21:25
-
I find this discussion somewhat revealing. http://c2.com/cgi/wiki?WhatsaControllerAnyway – huggie Mar 17 '14 at 07:09
Here is a naive description of MVC : http://www.devcodenote.com/2015/04/mvc-model-view-controller.html
A snippet:
Definition : It is a design pattern which separates an application into multiple layers of functionality.
The layers:
Model Represents data. It acts as an interface between the database and the application (as a data object). It will handle validations, associations, transactions etc.
Controller It gathers and processes data. Handles code which does data selection and data messaging.
View Displays output to the users.

- 4,478
- 8
- 34
- 51
MVC Design Pattern:
4 parts = User, View, Controller, Model.
User: - sees the View and uses the Controller.
Model: - holds the data and updates the Model that there is new data/state.
View: - displays the data that the Model has.
Controller: - takes the request from the user to get or set information, then communicates with either the View or Model, resp. - it "gets" via the View. - it "sets" via the Model.

- 1,717
- 21
- 20
As the tag on your question states its a design pattern. But that probably doesn't help you. Basically what it is, is a way to organize your code into logical groupings that keep the various pieces separate and easily modifiable.
Simplification:
- Model = Data structure / Business Logic
- View = Output layer (i.e HTML code)
- Controller = Message transfer layer
So when people talk about MVC what they are talking about is dividing up there code into these logical groups to keep it clean and structured, and hopefully loosely coupled. By following this design pattern you should be able to build applications that could have there View completely changed into something else without ever having to touch your controller or model (i.e. switching from HTML to RSS).
There are tons and tons of tutorials out there just google for it and I'm sure you'll turn up at least one that will explain it in terms that click with you.

- 212
- 2
- 10

- 1,792
- 1
- 11
- 22
Wikipedia seems to describe it best so far:
http://en.wikipedia.org/wiki/Model-view-controller
Model-view-controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other. In MVC, the model represents the information (the data) of the application and the business rules used to manipulate the data; the view corresponds to elements of the user interface such as text, checkbox items, and so forth; and the controller manages details involving the communication to the model of user actions such as keystrokes and mouse movements

- 29,502
- 35
- 121
- 166
The MVC or Model-View-Controller User Interface Paradigm was first described by Trygve Reenskaug of the Xerox PARC. In first appeared in print in Byte magazine volume 6, number 8, in August of 1981.

- 22,002
- 26
- 104
- 152
-
Xerox PARC also invented smalltalk, and MVC was a fundamental concept of it. – FlySwat Sep 24 '08 at 21:17
-
Here is Reenskaug's article... http://folk.uio.no/trygver/2003/javazone-jaoo/MVC_pattern.pdf – dacracot Sep 10 '09 at 14:28
This What is MVC blog article on Oreilly has you covered.

- 75,147
- 17
- 214
- 392

- 28,118
- 6
- 68
- 71
-
what is the difference between application logic and business logic? because in this article it says model contains business logic and controller contains application logic. I'm confused with that. – Jaywith.7 Jun 30 '09 at 05:59
-
I think the article is trying to draw a distinction between code that is directly related to the problem(s) you are solving (thats the code in the models - for example calculating an invoice total) and the code that is responsible for directing requests and passing information around (thats the code in the controllers - handling get/post and response formats, etc). I don't think calling them business and application logic was the best choice of words. – Chris Cherry Jul 01 '09 at 06:44
MVC is a software architecture pattern that separates representation from user interaction. Generally, the model consists of application data and functions that interact with it, while the view presents this data to the user; the controller mediates between the two.

- 27
- 10
It is a way of separating the underlying functionality of your application (model) from the way it interacts with the user (view). The controller coordinates how the model and view talk to each other.
Whilst it is all the rage at the moment, it is important to remember that preventing the model itself being able to determine exactly how its data is presented to the user can seen as a negative thing. The most obvious example is with HTML. The original intention of HTML was that there should be a clear separation of the model (HTML) from the view (rendered webpage) via a controller (the browser). There has been such a backlash against this original intention that browsers are criticised if they do not render a page pixel perfect to the designer's desired view.

- 42,717
- 16
- 86
- 131
MVC is a way to partition a user interface element into 3 distinct concepts. The model is the data on which the interface operates. The view is how the element is represented visually (or maybe audibly?). The controller is the logic that operates on the data.
For example, if you have some text you want to manipulate in a UI. A simple string could represent the data. The view could be a text field. The controller is the logic that translates input from the user - say character or mouse input - and makes changes to the underlying data model.

- 16,087
- 8
- 51
- 67
-
1This is fake Web MVC...In real MVC, the controller is simply the IO bridge, and the model does all data manipulation. – FlySwat Sep 24 '08 at 21:02
Like many have said already, MVC is a design pattern. I'm teaching one of my coworkers now and have explained it this way:
Models - The data access layer. This can be direct data access, web services, etc
Views - The presentation layer of your application.
Controllers - This is the business logic for your application.
This pattern enhances test-driven development.

- 7,910
- 15
- 56
- 95