Spiegato, Home

Technology and Gadgets

What Is Model-View-Controller?

  • Published by Spiegato
  • 2 min read

Model-view-controller (MVC) is a type of software architecture and design pattern that segments each element of a program into well-defined areas of functionality. In model-view-controller architecture, the model deals with all the internal program logic that manipulates, saves, retrieves and otherwise handles and calculates data. The view aspect is responsible for displaying information from the model for the user, and it also provides a way for the user to give input to the program. The controller takes input from the view, assesses or otherwise processes it and interacts with the model to change data or the program state, which ultimately is shown to the user through the view. Although the model-viewer-controller design calls for a program to encapsulate functionality, the three sections still need to interact with one another in some way and generally are dependent on one another in some sense, unlike other more aggressive design patterns.

Quite often, the model-view-controller pattern is seen in applications that manage a graphical user interface (GUI). Using the MVC pattern, the different visual elements of the GUI are handled by the view, the recording and processing of where and what a user clicks is handled by the controller, and actually changing information or loading information is done by the model. Depending on the exact design of an application, each component of the MVC pattern can have a mechanism to interact with the other components, such as the model being able to directly instruct the view to refresh the screen or the view having a way to tell the controller that it is refreshing the screen and not to accept new input. Unlike some design patterns that take a strict black-box approach, model-view-controller programs tend to be slightly more flexible, although some implementations can make an MVC program difficult to change or debug modularly.

In certain instances, the model-view-controller pattern does not have to contain only one of each component. One example is an application that has multiple views, such as multiple monitors, or a display that can be seen on several client devices. Multiple views and controllers can be used in an application that allows many users to access a database, all answering to a single model. It is more common, however, to design systems that maintain a one-to-one ratio of the model-view-controller components.

Even though model-view-controller components have a reliance on one another, it can be much easier to modify certain parts of a system that use the MVC pattern than if no pattern were used at all, especially in the case of non-object oriented applications. If an application uses callbacks or listeners and observers to implement interactions between the components, then each component can be changed without affecting the other two. This means a new GUI could be implemented without affecting the model or controller. It should be noted, however, that fundamental changes to a model-view-controller system might require some small amount of re-coding for each individual component.

Key terms in this article

Related articles

  • What is Google® Street View?

    Google® Street View is a computer application that provides high resolution images of locations that match up with the Google ® Maps application. Since…

  • What Is a Materialized View?

    The materialized view is a database object in which information requested from a database is displayed. A database is a collection of information arranged…

  • How can I View the EXIF Data of a Photograph?

    Traditionally, EXIF data was accessible only with software that had to be loaded onto a local computer. In order to make image file data easily accessible…

  • What Unusual Places Can You See on Google Street View?

    Google Street View, a popular feature of Google Maps and Google Earth, was launched in 2007 and eventually expanded to allow users to look at many…

  • What is a Pet’s Eye View Camera?

    The Pet’s Eye View Camera™ is a small digital camera that is intended to be clipped to a pet’s collar. This camera takes pictures automatically in one-…