Model–view–controller (MVC) is a software pattern for implementing user interfaces. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user. The central component, the model, consists of application data, business rules, logic, and functions. A view can be any output representation of information, such as a chart or a diagram. Multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants. The third part, the controller, accepts input and converts it to commands for the model or view.
In addition to dividing the application into three kinds of components, the Model–view–controller (MVC) design defines the interactions between them.
- A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document).
- A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. A passive implementation of MVC omits these notifications, because the application does not require them or the software platform does not support them.
- A view requests information from the model that it needs for generating an output representation to the user
Use in web applications
Although originally developed for personal computing, Model View Controller has been widely adopted as an architecture for World Wide Web applications in all major programming languages. Several commercial and noncommercial application frameworks have been created that enforce the pattern. These frameworks vary in their interpretations, mainly in the way that the MVC responsibilities are divided between the client and server.
Trygve Reenskaug introduced MVC into Smalltalk-76 while visiting Xerox Parc, in the 1970s; next, in the 1980s, Jim Althoff and others implemented a version of MVC for the Smalltalk-80 class library. Only later MVC was expressed as a general concept, in a 1988 article.
The MVC pattern evolved, but as a variant of the original concept, and because "parts of classic MVC don't really make sense for rich clients these days": HMVC, MVA, MVP, MVVM, and others that adapted MVC to different contexts.
- Hierarchical model–view–controller
- Model View ViewModel
- Observer pattern
- Three-tier architecture
- "More deeply, the framework exists to separate the representation of information from user interaction." The DCI Architecture: A New Vision of Object-Oriented Programming - Trygve Reenskaug and James Coplien - March 20, 2009.
- "... the user input, the modeling of the external world, and the visual feedback to the user are explicitly separated and handled by three types of object." Applications Programming in Smalltalk-80(TM):How to use Model-View-Controller (MVC).
- Simple Example of MVC (Model View Controller) Design Pattern for Abstraction
- Buschmann, Frank (1996) Pattern-Oriented Software Architecture.
- Leff, Avraham; James T. Rayfield (September 2001). "Web-Application Development Using the Model/View/Controller Design Pattern". IEEE Enterprise Distributed Object Computing Conference. pp. 118–127.
- Model View Controller History. C2.com (2012-05-11). Retrieved on 2013-12-09.
- Notes and Historical documents from Trygve Reenskaug, inventor of MVC.
- "A note on DynaBook requirements", Trygve Reenskaug, 22 March 1979, SysReq.pdf.
- Krasner, Glenn E.; Stephen T. Pope (Aug/Sep 1988). "A cookbook for using the model-view controller user interface paradigm in Smalltalk-80". The JOT (SIGS Publications). Also published as "A Description of the Model-View-Controller User Interface Paradigm in the Smalltalk-80 System" (Report), ParcPlace Systems; Retrieved 2012-06-05.
- The evolution of MVC and other UI architectures from Martin Fowler.
- Model-View-Controller Pattern in WikiBooks.
- What Are The Benefits of MVC? - quotes at length from the Gang of Four (software).
- An OpenGL simple example.
- Take MVC to the next level in .NET
- YouTube: MVC (Model View Controller) - A quick explanation.