Browse Definitions :

model-view-controller (MVC)

What is model-view-controller (MVC)?

In programming, model-view-controller (MVC) is an architectural design pattern that organizes an application's logic into distinct layers, each of which carries out a specific set of tasks. The layers also interact with each other to ensure that the application's functionality is delivered in a coordinated and consistent manner. The MVC methodology incorporates the entire application, from the user interface (UI) to the underlying data model.

The MVC system, which originated in the 1970s in connection with building graphical UIs, is widely used in program development, especially for today's web applications and object-oriented programming (OOP). Developers use a range of programming languages, including Java, Python, JavaScript, C#, Swift, Perl and PHP, to build applications based on MVC. Most of these languages also have MVC frameworks available to them to help streamline the development process. Popular MVC frameworks include Django, Ruby on Rails, Symfony, Catalyst and CherryPy, among many others.

MVC offers development teams important benefits. Programmers can build components simultaneously without stepping over each other's work, and they can reuse components. They can also deploy and maintain the components independently from others. MVC makes it easier to build large, complex applications, leading to faster, more efficient development efforts. In addition, MVC supports test-driven development, while making it possible to test and troubleshoot components individually.

MVC design layers

The MVC methodology separates an application's logic into three distinct layers:

  1. Model. The model layer is responsible for the application's data logic and storing and retrieving data from back-end data stores. The model layer might also include mechanisms for validating data and carrying out other data-related tasks. This layer is responsible for maintaining all aspects of the data and ensuring its integrity and accessibility.
  2. View. The view layer provides the UI necessary to interact with the application. It includes components needed to display the data and enables users to interact with that data. For example, the view layer might include buttons, links, tables, drop-down lists or text boxes.
  3. Controller. The controller layer contains the application logic necessary to facilitate communications across the application, acting as an interface between the view and model layers. The controller is sometimes viewed as the brains of the application, keeping everything moving and in sync.

It can be difficult to describe the three layers in specific terms because MVC can be implemented in different ways. For example, some developers use MVC frameworks to build their application, and these frameworks can differ from one product to the next in terms of how they implement MVC. In addition, each development team can have its own preferences for how it builds MVC-based apps, and those preferences can vary between development projects.

Conceptualizing model-view-controller

Conceptually, however, each approach to MVC development is similar in that they all attempt to follow the principle of separation of concerns (SoC), a design model that divides an application into distinct units with minimal overlap in functionality.

Figure 1 shows one way to conceptualize MVC. In this approach, the controller handles all user interaction, such as when the user clicks a button or selects a value from a list. The controller also feeds data to the view component in response to user requests. In addition, the controller interfaces with the model component, which sends updated data to the view element. The view component is concerned only with rendering the data provided by the controller, model or both.

diagram of the model-view-controller (MVC) model
Figure 1. This illustrates one way to conceptualize the MVC application architectural design pattern model.

The amount of responsibility assigned to each component and the communication flow between them depend on the individual implementation. For example, the controller might handle data validation, or it might pass that responsibility onto the model. Or the controller might make all decisions about user input or let the view component perform the initial filtering, such as determining whether simple actions should be handled by the view component or the controller.

Development teams should have a good sense of how they conceptualize MVC before they start to design and build their applications. For example, in Figure 1, communication occurs between the view element and model and between the view component and controller. But not all teams plan their implementations this way. They might, for example, decide that the model should never communicate with the view or the entire structure should follow a strict linear process, as in Figure 2.

diagram of linear model-view-controller (MVC)
Figure 2. This conceptualizes a linear approach to the MVC application architectural design pattern model.

In this linear approach, users interact solely with the view element through a browser, the view interacts solely with the controller and the controller interacts solely with the model.

Each development team may have its own interpretation of how MVC should be implemented. If it's using an MVC framework, it might also need to work around how the framework structures an application. The important point is that the team adheres to the SoC principle when designing and building its applications, with each component responsible for a discrete set of tasks.

Learn about five types of software architecture design worth knowing, and compare the MVC vs. model-view-viewmodel architecture patterns for application modularity. Check out five proven patterns for resilient software architecture design.

This was last updated in September 2023

Continue Reading About model-view-controller (MVC)

  • telecommunications (telecom)

    Telecommunications, also known as telecom, is the exchange of information over significant distances by electronic means and ...

  • remote infrastructure management

    Remote infrastructure management, or RIM, is a comprehensive approach to handling and overseeing an organization's IT ...

  • port address translation (PAT)

    Port address translation (PAT) is a type of network address translation (NAT) that maps a network's private internal IPv4 ...

  • ISO 31000 Risk Management

    The ISO 31000 Risk Management framework is an international standard that provides organizations with guidelines and principles ...

  • voice squatting

    Voice squatting is an attack vector for voice user interfaces, or VUIs, that exploits homonyms -- words that sound the same, but ...

  • multifactor authentication

    Multifactor authentication (MFA) is an account login process that requires multiple methods of authentication from independent ...

  • Whistleblower Protection Act

    The Whistleblower Protection Act of 1989 is a law that protects federal government employees in the United States from ...

  • skunkworks project (Skunk Works)

    A skunkworks project, also known as Skunk Works, is an innovative undertaking, involving a small group of people, that is outside...

  • digital innovation

    Digital innovation is the adoption of modern digital technologies by a business.

  • employee onboarding and offboarding

    Employee onboarding involves all the steps needed to get a new employee successfully deployed and productive, while offboarding ...

  • skill-based learning

    Skill-based learning develops students through hands-on practice and real-world application.

  • gamification

    Gamification is a strategy that integrates entertaining and immersive gaming elements into nongame contexts to enhance engagement...

Customer Experience
  • virtual assistant (AI assistant)

    A virtual assistant, also called an AI assistant or digital assistant, is an application program that understands natural ...

  • Microsoft Dynamics 365

    Dynamics 365 is a cloud-based portfolio of business applications from Microsoft that are designed to help organizations improve ...

  • Salesforce Commerce Cloud

    Salesforce Commerce Cloud is a cloud-based suite of products that enable e-commerce businesses to set up e-commerce sites, drive ...