MVC Architecture

Simply what is the MVC Architecture???

Minindu Kothalawala
3 min readMar 8, 2021

M — Model

The part that stores data and its related logics.

  • It represent data that is being transferred between controller components or any other related business logics.
  • It responds to the request from the view and also response to instructions from the controller to update itself.
  • It is the lowest level of the pattern which is responsible for maintaining data.

VView

Part of the application that represents the presentation of data.

  • View request from the model to give information so that it represents the output presentation to the user.

CController

The part of the application that handles the user interactions.

  • The controller interprets the mouse and keyboard inputs from user then inform to model and view to change.
  • Controller work as the interface in between the view and model.

Lets clarify the MVC by going through the simple real world example.

  • We all have experience with restaurants in our day today life.
  • When we go to restaurant, we give our order to waiter then he go to the kitchen and give our order to the cook.
  • After cook getting the our order, he get the ingredients from the store or refrigerator and prepare the order.
  • Then the servant serve it to us.
  • In here,

Model‘Cook’ works as the model. Because cook made our request by using data which are inside the database called “refrigerator”.

View‘Our order’ can be consider as the view. That is what we request from waiter (controller) and which is prepared by the cook (model).

Controller → ‘Waiter’ works as the controller in this scenario. Because waiter is the “interface” that we communicate with cook. Waiter getting our request and tells to the cook what he need to prepare.

What are the Advantages and Disadvantages of MVC Architecture???

Advantages:

  • Easy to extend and grow.
  • Easier support for new type of client.
  • All classes and objects are independent of each other, so that they can test them separately.
  • Can develop various components parallelly.
  • It helps us to avoid the complexity of our project by dividing it in to three components.
  • It works well for web apps which are supported by large team of designers and developers.
  • Search engine optimization (SEO) friendly.

Disadvantages:

  • Difficult to read, change to unit tests and reuse this models.
  • Need to multiple programmers to conduct parallel programming.
  • Knowledge of multiple technologies is must.
  • Maintenance is harder because there are lots of codes in controller.

Conclusion:

  • The MVC is an architectural pattern that separates an application into
  1. Model → It includes all the data and its related logic.
  2. View → Represents the data to the user.
  3. Controller → An interface between Model and View components and handle the user interactions.
  • MVC architecture first discussed in 1979 by Trygve Reenskaug.
  • It is a highly testable, extensible and pluggable framework.
  • Some popular MVC frameworks are, Rails, Zend Framework, CodeIgniter, Laravel, Fuel PHP.

--

--