Model–view–controller
MVC was first described in 1979 by Trygve Reenskaug, then working on Smalltalk at Xerox PARC. The original implementation is described in depth in the influential paper "Applications Programming in Smalltalk-80: How to use Model View Controller".
There have been several derivatives of MVC. For example, Model View Presenter is used with the .NET Framework, and the XForms standard uses a "model-view-controller-connector architecture". However, standard MVC remains popular.
Model view controller is both an architectural pattern and a design pattern, depending on where it is used.
As an architectural pattern
It is common to split an application into separate layers that can be analyzed, and sometimes implemented, separately.
MVC is often seen in web applications, where the view is the actual HTML or XHTML page, and the controller is the code that gathers dynamic data and generates the content within the HTML or XHTML. Finally, the model is represented by the actual content, which is often stored in a database or in XML nodes, and the business rules that transform that content based on user actions.
Though MVC comes in different flavors, control flow is generally as follows:
Some implementations such as the W3C XForms also use the concept of a dependency graph to automate the updating of views when data in the model changes.
By decoupling models and views, MVC helps to reduce the complexity in architectural design and to increase flexibility and reuse of code.
As a design pattern
MVC encompasses more of the architecture of an application than is typical for a design pattern. When considered as a design pattern, MVC is semantically similar to the Observer pattern.
Model
Is the domain-specific representation of the data on which the application operates. Domain logic adds meaning to raw data (for example, calculating whether today is the user's birthday, or the totals, taxes, and shipping charges for shopping cart items).
Many applications use a persistent storage mechanism (such as a database) to store data. MVC does not specifically mention the data access layer because it is understood to be underneath or encapsulated by the model.
View
Renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes.
Controller
Processes and responds to events (typically user actions) and may indirectly invoke changes on the model.
There have been several derivatives of MVC. For example, Model View Presenter is used with the .NET Framework, and the XForms standard uses a "model-view-controller-connector architecture". However, standard MVC remains popular.
Model view controller is both an architectural pattern and a design pattern, depending on where it is used.
As an architectural pattern
It is common to split an application into separate layers that can be analyzed, and sometimes implemented, separately.
MVC is often seen in web applications, where the view is the actual HTML or XHTML page, and the controller is the code that gathers dynamic data and generates the content within the HTML or XHTML. Finally, the model is represented by the actual content, which is often stored in a database or in XML nodes, and the business rules that transform that content based on user actions.
Though MVC comes in different flavors, control flow is generally as follows:
- The user interacts with the user interface in some way (for example, presses a mouse button).
- The controller handles the input event from the user interface, often via a registered handler or callback.
- The controller notifies the model of the user action, possibly resulting in a change in the model's state. (For example, the controller updates the user's shopping cart.)
- A view uses the model indirectly to generate an appropriate user interface (for example, the view lists the shopping cart's contents). The view gets its own data from the model. The model and controller have no direct knowledge of the view.
- The user interface waits for further user interactions, which restarts the cycle.
Some implementations such as the W3C XForms also use the concept of a dependency graph to automate the updating of views when data in the model changes.
By decoupling models and views, MVC helps to reduce the complexity in architectural design and to increase flexibility and reuse of code.
As a design pattern
MVC encompasses more of the architecture of an application than is typical for a design pattern. When considered as a design pattern, MVC is semantically similar to the Observer pattern.
Model
Is the domain-specific representation of the data on which the application operates. Domain logic adds meaning to raw data (for example, calculating whether today is the user's birthday, or the totals, taxes, and shipping charges for shopping cart items).
Many applications use a persistent storage mechanism (such as a database) to store data. MVC does not specifically mention the data access layer because it is understood to be underneath or encapsulated by the model.
View
Renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes.
Controller
Processes and responds to events (typically user actions) and may indirectly invoke changes on the model.


0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home