Model-View-Controller: A Special N-Tier Architecture

Learn about MVC architecture and its pros and cons.

Overview

Model-view-controller (MVC) is a widely used software architecture pattern that provides a structured and organized way to design and develop applications. It divides an application into three primary components, each with its distinct role:

  • Model
  • View
  • Controller

Model

The model represents the business logic and data of the application. It’s responsible for maintaining the state of the application and for performing operations on the data. The model is typically implemented as a set of classes that represent the data and operations that can be performed on it.

View

The view is responsible for rendering the user interface of the application. It receives data from the model and presents it to the user in an appropriate format. The view is typically implemented as templates or scripts that generate the HTML, CSS, and JavaScript code needed to display the user interface.

Controller

The controller is responsible for handling user input and interactions. It receives requests from the view and sends them to the model to be processed. The controller also receives data from the model and sends it to the view to be displayed. The controller is typically implemented as a set of classes or functions that handle the routing and processing of requests.

Here’s a diagram illustrating the relationship between the model, view, and controller in MVC architecture:

Get hands-on with 1200+ tech skills courses.