Traditional Model-View-Controller

Model-View-Updater

Definition
A UI pattern that separates the visual representation (View), the domain model (Model), and the code needed to connect the two (Controller), allowing the view to read directly from the model.

This is the oldest UI pattern. Its original strength was the separation of model, view, and controller. But since there's now also the Model-View-Adapter pattern, its distinguishing feature is the fact that the view reads from the model. It's still used by simple web applications where the view accesses the database in order to find the information to display.

Model-View-Controller architecture diagram

The model contains the data and the domain logic of the application.

The view is the visual representation of the component that allows the user to interact with the application.

The controller provides the wiring of the application: reading from the UI, writing to the model, error handling, navigation.

Examples

  • Plain PHP websites where the view contains a mix of markup and PHP code, but where the domain logic is carefully placed into a separate module.

Where does it come from?

The MVC architecture was developed as part of the Smalltalk group at the famous Xerox PARC. It is usually credited to the Norwegian Trygve Reenskaug, who worked there as a visiting scientist in 1978/1979. MVC is since then an integral part of the Smalltalk programming language.

When should you use it?

Separating view code from model code is always a good idea. It allows both of them to be tested in isolation and leads to less code duplication.

Problems

  • The view is tied to the model. If the same view needs to be used with a different model, it needs to be duplicated.

Common implementation techniques

  • Registering views with a model to receive change notifications is typically implemented by the Observer Design Pattern.

Links