DEV Community

loading...
Cover image for Things you must know about MVC architecture

Things you must know about MVC architecture

Sahan Akalanka
Backend Developer | PHP | Laravel
・1 min read

Alt Text

MVC is an architectural pattern which has three parts Model, View and Controller.it was used for desktop graphical user interfaces but nowadays is used in designing mobile and web apps.

This architectural pattern was invented by Trgve Reenskaug and in that time it was called "Thing Model View Editor" but rapidly change it to "Model View Controller".The goal was Trygve Reenskaug was to solve the problem of users controlling a large and complex data set.Currently MVC is used for designing web applications.some web frameworks that use MVC concept: Ruby on Rails, Laravel, Zend framework, CherryPy, Symphony, etc.

In this architectural pattern there are three main components and each of them has specific responsibilities,

-Model
Model is responsible for maintaining data.The model is connected to the database so anything you do with data , adding or retrieving data is done in the model component.It responds to the controller requests because the controller never talks to the database by itself.The model talks to the database back and forth an then it gives the needed data to the controller.
Note:The model never communicated with the view directly.

-View
It actually user interface.Data representation is by the View.

-Controller
Controller is the main part of these three components because controller is the component that enables the interconnection between the View and Model it act as an intermediary.The controller doesn't have to worry about worry about handling data logic,it just tells the model to what to do.
Note:View and Model can't talk directly.

Discussion (0)