Saturday, June 6, 2020

Introduction To MVC Architecture


MVC
stands for  Model View Controller

It is an architectural pattern, an architectural pattern governs the entire architecture of our application. It is a kind of design pattern only, but it has a broader scope.
For example, normal design patterns are used to solve specific technical problems whereas architectural design patterns are used to solve a large architectural problem. So it basically affects the entire architecture of our application.

MVC divides software into three parts:
  1. MODEL
  2. VIEW
  3. CONTROLLER
So, this is called separation of concerns. So each of these components will have some specific responsibilities.

Now let's see how an MVC pattern is applicable in a web application

The three main components of any web application are Server, Client, and Database.


                                                                       Figure 1.


The client will send a request to the server, then the controller will take that request and pass it to the model. The model will interact with the database, and in the process, it may also execute some business logic if required, then after getting the data from the database, it will pass it to the controller. Then the controller will pass that data to the view, then the view will format the data, and that formatted data will be sent to the client. So this is how our architecture works.


Now if we consider a Java application, it looks like this:


                                                                                                                Figure 2.


Now how these three components interact with each other, that might be different for different MVC framework. But the overall picture remains, the same, i.e, the application will be divided into three parts. There will be a Model, View, and Controller.



No comments:

Post a Comment

Introduction To MVC Architecture

MVC stands for  Model View Controller It is an architectural pattern, an architectural pattern governs the entire architecture of our applic...