Glossary termArchitectural pattern

Model-View-Controller

Also known as: MVC

Software architecture pattern that separates an application into a data model, views that display it and controllers that handle user input.

Model-view-controller (MVC) divides an interactive application into three roles. The model holds the data and the rules for changing it, such as the contents of a shopping cart and how totals are calculated. The view presents that data to the user, for instance as a web page or a window. The controller receives user input, such as clicks and form submissions, and translates it into operations on the model, after which the views update to reflect the changes. Keeping these concerns apart means each can be modified with less risk of breaking the others.

Trygve Reenskaug formulated MVC in the late 1970s while a visiting scientist at Xerox PARC, and it was used in the Smalltalk-80 environment for building graphical interfaces. The pattern later became the organizing idea of many web frameworks, including Ruby on Rails, Laravel and ASP.NET MVC, in which controllers handle HTTP requests, models map to database tables and views render HTML templates. Variants such as model-view-presenter and model-view-viewmodel adjust how the pieces communicate, especially in user interface toolkits built around data binding.

MVC is one of the most influential design patterns, and its central lesson, separating data and logic from presentation, appears throughout user interface engineering. It makes it possible to offer several views of the same data, test business logic without a user interface and divide work among specialists. Its meaning has stretched over time, so different frameworks use the term for noticeably different structures. Component-based libraries such as React moved away from strict MVC, combining view and controller logic within components while managing application state separately.

Key points

  • MVC splits an application into a model for data and rules, views for presentation and controllers for input.
  • Trygve Reenskaug devised the pattern at Xerox PARC in the late 1970s for Smalltalk applications.
  • Web frameworks such as Ruby on Rails adapted MVC to handling HTTP requests and rendering pages.
  • Separating presentation from logic allows multiple views of the same data and easier testing of business rules.

Related entries

Glossary term

Design Pattern

Programming

Reusable, named solution to a commonly recurring problem in software design, described as a template rather than as finished code.

Glossary term

Programming paradigm that organizes software around objects, which bundle data with the methods that operate on it and interact by sending messages.

Glossary term

Reusable software platform that provides a predefined structure and calls developer-written code at set points, shaping how an application is built.

Organization

Xerox PARC

HardwareProgrammingIdeas and Culture

Research center founded by Xerox in Palo Alto in 1970, where the Alto computer, Ethernet, laser printing and modern graphical interfaces took shape.

Technology

React

Programming

Open-source JavaScript library from Meta for building user interfaces out of reusable components that update efficiently when data changes.

Glossary term

Web application that loads a single HTML page and then updates its content with JavaScript instead of loading fresh pages from the server.

Glossary term

Abstraction

Programming

Principle of managing complexity by hiding details behind simpler interfaces, so a component can be used without knowing how it works inside.