Browse Definitions :
Definition

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)

Networking
  • firewall as a service (FWaaS)

    Firewall as a service (FWaaS), also known as a cloud firewall, is a service that provides cloud-based network traffic analysis ...

  • private 5G

    Private 5G is a wireless network technology that delivers 5G cellular connectivity for private network use cases.

  • NFVi (network functions virtualization infrastructure)

    NFVi (network functions virtualization infrastructure) encompasses all of the networking hardware and software needed to support ...

Security
  • virus (computer virus)

    A computer virus is a type of malware that attaches itself to a program or file. A virus can replicate and spread across an ...

  • Certified Information Security Manager (CISM)

    Certified Information Security Manager (CISM) is an advanced certification that indicates that an individual possesses the ...

  • cryptography

    Cryptography is a method of protecting information and communications using codes, so that only those for whom the information is...

CIO
  • B2B (business to business)

    B2B (business-to-business) is a type of commerce involving the exchange of products, services or information between businesses, ...

  • return on investment (ROI)

    Return on investment (ROI) is a crucial financial metric investors and businesses use to evaluate an investment's efficiency or ...

  • big data as a service (BDaaS)

    Big data as a service (BDaS) is the delivery of data platforms and tools by a cloud provider to help organizations process, ...

HRSoftware
  • talent acquisition

    Talent acquisition is the strategic process an organization uses to identify, recruit and hire the people it needs to achieve its...

  • human capital management (HCM)

    Human capital management (HCM) is a comprehensive set of practices and tools used for recruiting, managing and developing ...

  • Betterworks

    Betterworks is performance management software that helps workforces and organizations to improve manager effectiveness and ...

Customer Experience
  • martech (marketing technology)

    Martech (marketing technology) refers to the integration of software tools, platforms, and applications designed to streamline ...

  • transactional marketing

    Transactional marketing is a business strategy that focuses on single, point-of-sale transactions.

  • customer profiling

    Customer profiling is the detailed and systematic process of constructing a clear portrait of a company's ideal customer by ...

Close