What is MVC and Why use MVC?

Model View Controller (MVC)

The MVC is an architecture pattern that separates an application into three main logical components Model, View, and Controller. Each of these components has its own role in a Project.

MVC model was first introduced in 1987 in the Smalltalk programming language. More than 80% of all web app frameworks rely on the Model View Controller.

MVC Architecture

Now let’s describe below in brief.

Model

The model is responsible for getting data from a database, packaging it in data objects that can be understood by other components, and delivering those objects, most of which will happen in response to input from the controller.

View

It represents how data should be presented to the application user. Users can read or write the data from view. Basically it is responsible for showing end-user content, we can say it is the user interface. It may consist of HTML, CSS, JS.

Controller

The user can send a request by interacting with the view, the controller handles these request and send to Model then get appropriate response from the Model, sends the response to View.

It may also have required logics.
It works as a mediator between View and Model.

Why use MVC

  • Organized Code
  • Independent Block
  • Reduces the complexity of web applications.
  • Easy to Maintain.
  • Easy to modify.

Basic Structure

Assets
– CSS
– Images
– JS
Config
-Database Config File
Controllers
Model
Views

Advantages

  • Multiple developers can work simultaneously on the model, controller, and views.
  • MVC enables logical grouping of related actions on a controller together. The views for a specific model are also grouped together.
  • Models can have multiple views.

Disadvantages

  • The framework navigation can be complex because it introduces new layers of abstraction and requires users to adapt to the decomposition criteria of MVC.
  • Knowledge of multiple technologies becomes the norm. Developers using MVC need to be skilled in multiple technologies.

Popular MVC web frameworks

  • Laravel
  • Ruby on Rails
  • Zend Framework
  • Django
  • CakePHP…etc.

For more information about MVC.

Total Page Visits: 116 - Today Page Visits: 0