DEV Community

Fernando Lucas
Fernando Lucas

Posted on

What is MVC pattern?

What is the MVC pattern?

MVC pattern is a famous software architecture that separates the system and the development in 3 components - Model, View and Controller. Each component has its own function and communicates with others. MVC allows the code to be more organized and simple to keep and update.


In the Model, we process the data, make connections with the database and store data. Model is independent from View, that is, Model isn’t responsible for the way we show this data to the user.


View is responsible for showing to the user the data, through an interface. That is, View is the user’s part. The user can send data, see data and take actions. In other words, the View is the front-end part.


Controller is responsible for making a bridge between View and Model. Controller gets data, processes this data and sends this data to the Model. A simple and daily example is a login system. We have the Model, with a database and one table User. We have the interface, with two fields, maybe one is password field and a button. Between these two, we have the Controller. When we press the button ‘login’, We take this data and send it to the Controller, and it will check if this data exists in the database, and will make all the processes, if it exists or not.

Top comments (0)