An Overview Of MVC

In this article I will give an overview of Model View Controller (MVC).

Before discussing MVC we will discuss about one scenario and the scenario is about construction of a bridge. There are 2 ways to construct a bridge. And these ways are:

  1. Traditional Way
  2. Modern way

Bridge which has been constructed in a traditional way will not be earthquake proof and also the look of the bridge will not be effective. But bridge which has constructed in modern way (scientific way) will be more trusted with less fear of collapsing than the bridge which has been constructed in Traditional way. Also the look of bridge which has constructed in modern way will be more effective.

Difference between Modern and Traditional way of Constructing Bridge.

Traditional way Modern Way(Scientific way)
1. This bridge will not be more trusted. Because there is more chance of collapsing this bridge. 1. This will be more effective because this bridge is earthquake proof so there is less chance of collapsing this bridge.
2. Look will not be more effective 2. Look will more effective.

What is MVC?

This is a design pattern to develop Application. This stands for Model, View, and Controller. In MVC design pattern code is divided in 3 parts as Model, View, Controller. This Model will contain Class and data of application. View will contain GUI code. Controller contains only business logic or Controller code as:

MVC

Why we use MVC?

We use MVC to develop application because Model view controller is loose coupling that is each and every block get interacted with another blocks. Also MVC application is light weight code means it contains less code compared to any other way of application development. The following figure has shown loose coupling of MVC application.

MVC loose coupling
                                          Figure: MVC loose coupling

The above figure shows a user is interacting to view page for displaying the output or result. User is making request for manipulating data on controller and controller is performing operation on Model and after performing operation, output is going to deliver on view page to User.

Advantages of MVC:

  1. More security.
  2. Testing is very easy.
  3. Effective GUI(Graphical user interface).
  4. Less code.
  5. Loose coupling.

Recap

Model view controller is a design pattern which is used to develop Application. MVC is loose couple bound that is each and every layer get interacted with another layer. Model view controller is light weight code as

Comparing MVC code and Other code
     Figure: Comparing MVC code and Other code