Close

MVC

[Last Updated: Mar 7, 2018]

Software Engineering Design Pattern 

MVC stands for Model View Controller.

This is a design pattern.

This pattern separates the presentation of information from

  • data
  • and process on data.

The central idea is code reusability and separation of concerns.


M (Model): The model consists of application data, business rules, logic, and functions. Model may communicate to database as well.


V (View): View is the presentation layer which shows UI components. That's what user sees and interacts.


C (Controller): A controller processes and responds to the events such as user requests/actions. It propagates changes in model to the view and vice-versa. It makes decisions. It controls what should happen.



Web MVC:

  • The Browser communicates with the controller. A controller is a part of a web application running on the server.

  • Controller based on the browser request make decisions what should happen.

  • If controller needs some data related to the business logic it ask that data from model.

  • Model might interact with database.

  • Once controller receives data from the model it sends that data to the presentation layer (the view).

  • The view prepare the presentation based on data provided by the controller and sends the presentation in a format which browser can understand.