What Is MVC Framework?
What Is MVC Framework?
What Is MVC Framework?
History of MVC
Features of MVC
MVC Architecture
MVC Examples
Popular MVC web frameworks
Advantages of MVC: Key Benefits
Disadvantages of using MVC
3-tier Architecture vs. MVC Architecture
History of MVC
MVC architecture was first discussed in 1979 by Trygve Reenskaug
MVC model was first introduced in 1987 in the Smalltalk programming
language.
MVC was first time accepted as a general concept, in a 1988 article
In the recent time, MVC pattern is widely used in modern web
applications
Features of MVC
Easy and frictionless testability. Highly testable, extensible and
pluggable framework
To design a web application architecture using the MVC pattern, it offers
full control over your HTML as well as your URLs
Leverage existing features provided by ASP.NET, JSP, Django, etc.
Clear separation of logic: Model, View, Controller. Separation of
application tasks viz. business logic, Ul logic, and input logic
URL Routing for SEO Friendly URLs. Powerful URL- mapping for
comprehensible and searchable URLs
Supports for Test Driven Development (TDD)
MVC Architecture
Here is the detailed architecture of MVC framework:
View
A View is that part of the application that represents the presentation of data.
Views are created by the data collected from the model data. A view requests
the model to give information so that it presents the output presentation to the
user.
The view also represents the data from charts, diagrams, and tables. For
example, any customer view will include all the UI components like text boxes,
drop downs, etc.
Controller
The Controller is that part of the application that handles the user interaction.
The controller interprets the mouse and keyboard inputs from the user,
informing model and the view to change as appropriate.
Model
The model component stores data and its related logic. It represents data that
is being transferred between controller components or any other related
business logic. For example, a Controller object will retrieve the customer info
from the database. It manipulates data and sends back to the database or
uses it to render the same data.
It responds to the request from the views and also responds to instructions
from the controller to update itself. It is also the lowest level of the pattern
which is responsible for maintaining data.
MVC Examples
Let’s see Model View Controller example from daily life:
Example 1:
Let’s assume you go to a restaurant. You will not go to the kitchen and
prepare food which you can surely do at your home. Instead, you go
there and wait for the waiter to come on.
Now the waiter comes to you, and you order the food. The waiter
doesn’t know who you are and what you want he just written down the
detail of your food order.
Then, the waiter moves to the kitchen. In the kitchen, waiter does not
prepare your food.
The cook prepares your food. The waiter is given your order to him
along with your table number.
Cook then prepared food for you. He uses ingredients to cooks the food.
Let’s assume that your order a vegetable sandwich. Then he needs
bread, tomato, potato, capsicum, onion, bit, cheese, etc. which he
sources from the refrigerator
Cook final hand over the food to the waiter. Now it is the job of the
waiter to moves this food outside the kitchen.
Now waiter knows which food you have ordered and how they are
served.
Example 2:
Car runs from engine take fuel from storage, but it runs only using mentioned
user interface devices.