Model View Controller (MVC) Framework

Model View Controller (MVC) Framework

Think of software that is managing your daily grocery needs or you are using it to play some music or maybe you are writing that mail to your boss you’ve been waiting for so long. All these things are happening through software, web, or mobile application. Agree??

So how do people responsible for making these are managing it? There must be a bunch of computer engineers working behind the scenes who make sure you don’t run away after looking at the design. Someone to manage what will happen when you click that login button and another to safely preserve your data. Sounds overwhelming right??

Model-view-controller is just an answer.

What is MVC?

It is a methodology or a design pattern developed so that each component used in making software gets undivided attention. This eases up the managing of different parts of a software product. It segregates the whole software into three components – Model, View, Controller.

This approach is common in modern-day’s frameworks like Laravel (PHP Framework), Angular, React (JS Framework), and so on.

Why MVC is needed?

MVC facilitates individuals with different sets of skills to work on different software parts simultaneously without disturbing each others’ workflow. By following the MVC pattern, a UI developer can focus on the front-end (View), Without bothering the one who is writing backend logic (Controller) or the other responsible for forming database queries (Model).

Components of MVC

MVC approach breaks down the whole software or application into three elements – Model, View, and controller. Each of them contributes differently to the making of the final product.

1. Model

Model fulfills the data needs of the application. It is responsible to perform database operations like fetching, adding, updating, and deleting the data into a database to be further used by our application.

Models are mapped to their corresponding tables in the database.

For example – The orders table in the database will be represented by Order Model in our application.

2. View

It is the UI or User-interface through which the end-user communicates to your application. The view is the webpage of a software screen or a website that is presented to the user to perform some task.

3. Controller

The controller acts as a bridge between the above two parts – model and view. It is the place where all the business logic or the algorithm to make things work in the software resides. It effectively uses what operation is performed on data (Model) and what to ultimately show to the end-users( View) via some algorithm.

Enough of the technical stuff, Let’s understand the whole architecture through an example.

Example

Let’s say you have gone to your favorite restaurant to have some Italian or Chinese. You call the waiter and you are presented with the menu. You then order a dish and the waiter goes to ask the chef about your order.

Now here the process of how the dish is made, the ingredients that go in, and the correct temperature to make it can act as CONTROLLER. It is the main process of how the dish is made. Now chef will also fetch the ingredients from the pantry, so Pantry here is MODEL and lastly, the final dish that is presented to the customer will act as VIEW.

Conclusion

MVC is used in almost every framework you will see today so, it’s important for us to clearly understand its fundamentals before jumping on to the actual implementation. And now that you got it, you are good to go.

Spread the love
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments