TOP

Model View Control

Model – View – Control

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[4], and the XForms standard uses a “model-view-controller-connector architecture”. However, standard MVC remains popular.

Overview

Though MVC comes in different flavors, control flow is generally as follows:

1.         The user interacts with the user interface in some way (for example, presses a mouse button).

2.         The controller handles the input event from the user interface, often via a registered handler or callback and converts the event into appropriate user action, understandable for the model.

3.         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.)

4.         A view queries the model in order 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 controller may (in some implementations) issue a general instruction to the view to render itself. In others, the view is automatically notified by the model of changes in state (Observer) which require a screen update.

5.         The user interface waits for further user interactions, which restarts the cycle.

Comments are closed.