MVC Architecture & MVC Life Cycle

Introduction

MVC stands for Model View Controller which is not a programming language but it is a design pattern which use to develop the application. The application which has developed using MVC design pattern will get divided in 3 Components. Which Model will contain all the data which will get retrieve on the request of user. View will contain UI code and Controller will contain Business logic code. For better understanding of MVC we will see graphical example of MVC

Example

Figure. Graphical Example of MVC

The Properties of MVC is.

  1. Loose Coupling
  2. Lightweight code
  3. Effective look
  4. Testing is Very Easy
  5. Rapid application integrated development.

MVC Architecture

The architecture of MVC can be seen in the following figure.

 MVC Architecture

Figure. MVC Architecture

Explanation

User will make request for the page which user would like to retrieve. Requested page will go to controller and on controller Route.Config will be checked. Requested page will get transfer to Model from Controller.

On Model there will be 2 steps.

  1. Page initialization will get started.
  2. Then result set will be generated.

After these operation result set will get unload to View through view engine.

Responsibility of view engine

  1. View Engine get the request from Controller
  2. The requested page will get executed
  3. The result got by the execution process will get deliver to View.

Life cycle of MVC

Life Cycle of MVC is in the following figure.

MVC

Figure. Life Cycle of MVC

Explanation of MVC Life Cycle

Step 1. User will make request for page

Step 2. Route.Config will get check on Controller

Step 3. After Route.Config validation request will get transfer from Controller to Model

Step 4. Page request will go to Model & on Model the following operation will perform.

  • Page initialization will start after the initialization of the page.
  • One result set will get generated.

Step 5. Generated result set will be delivered to the Controller from the Model.

On Model Page validation operation will perform.

Step 6. After page validation on controller, Page will deliver to View through View engine.

Step 7. Now user can see requested page as response page.

Life Cycle of MVC can be seen as in the following figure.

Life Cycle

Figure. Life Cycle of MVC

Explanation

  1. User will make page request.
  2. Route.Config of requested page will get checked on Controller.
  3. Page initialization will be performing on Model and after page initialization one result set will get generated.
  4. Generated Result set will be getting delivered to the Controller from Model.
  5. Result set will get validated (Page Validation) and after page validation Result set will get delivred to View through view engine.

Recap

MVC Stands for Model View Controller, which is a design pattern. MVC based developed application will get divided in 3 components. Each and every component will contain their own code only.


Similar Articles