Woodstock Blog

a tech blog for general algorithmic interview questions

[Design] Model–view–controller (MVC)

Overview

Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces.

From MIT handouts 3: MVC uses separate programming entities to store the data(model), display the data(view), and modify the data(controller).

Components

The central component of MVC, the model, captures the application’s behavior in terms of its problem domain, independent of the user interface. The model directly manages the application’s data, logic and rules.

A view can be any output representation of information, such as a chart or a diagram; multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants.

The third part, the controller, accepts input and converts it to commands for the model or view.

Early web MVC frameworks took a thin client approach that placed almost the entire MVC on server. As client technologies have matured, MVC components can be executed partly on the client(AJAX).

Other good explanation

MVC is a user interface design pattern.

  1. Controller – Represents interactions, typically with the mouse or keyboard, or in the case of web applications, in the form of HTTP requests.

  2. View – Renders the graphical output of the application

  3. Model – Everything else. In particular this includes the data and business logic.