Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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.

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.

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

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.

This What is MVC blog article on Oreilly has you covered.

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.

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.

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.

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top