What the hell is MVC???

Model, View, Controller…….what does it all mean?

Luke Wickens
2 min readNov 17, 2020

What does MVC stand for?

MVC stands for Model-View-Controller.

What is MVC?

MVC is an architectural design model. This basically means that it is a pattern (or model )that developers use to guide them while designing their code. It splits an application into three parts (take a guess what these are called)….

The model, the view, and the controller. Simple so far?

Photo by Jay Clark on Unsplash

But what ARE Model, View, and Controller?

The Model relates to all the data-related logic that the user works with. For example, think of a Google search (other search engines are available). You, the user, input your query, and Google provides you with all the matches related to your search query. The Model aspect of this example is the database of information.

The View component is used for all the UI logic. For example, we will use Google search again. The View is like the webpage that you see on the screen, the Google icon above the search box. That’s all the View.

Controllers act as the middle-man between the View and the Model, to process all the data logic and interactions, manipulates the data using the Model, and interacts with the View to display it. So in our Google search example, the controller is the bit in the middle. It takes the information the user inputs to the View, decides what information the user wants, feeds that into the Model, gets back the requested information from the Model, and then passes that information in a readable format back to the View.

The Model and View should never interact with each other unless it is through the Controller.

Photo by Glenn Carstens-Peters on Unsplash

Why should you use MVC?

MVC is a great tool for structuring your program’s files, using function to organize your code.

Using MVC applies structure to your code and causes you to think exactly how each segment of code interacts with each other. This will make reading your code easier, since there is a design pattern in place that can be followed. This isn’t just beneficial for the writer, this is also helpful for anyone else who needs to (at some point) read through your code.

--

--