Model View Controller (MVC) Overview

Model View Controller or MVC as it is popularly called, is a software design pattern for developing web applications. It is based on the premise of separation of responsibility. A Model View Controller pattern is made up of the following three parts:

  • Model: The lowest level of the pattern which is responsible for maintaining data.

  • View: This is responsible for displaying all or a portion of the data to the user.

  • Controller: Software Code that controls the interactions between the Model and View. And is responsible for coordinating between a model and view.

MVC is popular as it isolates the application logic from the user interface layer and supports separation of concerns. Any change in the model is reflected in the view and any change done by the user while interacting with the view is reflected back on the model. Here, the controller acts as a coordinator and is responsible for keeping the model and view in sync. The net effect of this separation is that the code becomes more organized, more understandable, and maintainable.

The model

The model is responsible for managing the data of the application. It responds to the request from the view and it also responds to instructions from the controller to update itself.

The view

A presentation of data in a particular format, triggered by a controller's decision to present the data.

The controller

The controller is responsible for responding to user input and performing interactions on the data model objects. The controller receives the input, it validates the input and then performs the business operation that modifies the state of the data model.

Ebook Download
View all
Learn
View all