What Exactly is MVC?

Jonathan Zavala
2 min readMar 18, 2022

MVC (Model-View-Controller) is a pattern in software design commonly used to implement user interfaces, data, and controlling logic. It helps with separation of concerns, it wouldn’t be good if we could access all users data from the display page we show other users now would it? As you can see there are three parts to MVC: Model, View and Controller. We’ll talk about all three and what they’re used for and how they help us!

Model

The model is where we should define the data the application contains. Say we’re building a bare bones e-commerce website, we would need: users, products and orders. Our model will tell the application I need the information for these three things from the database. It’s best practice for only our model to interact with our database, it’s best for separation of concerns and allows us to debug easier. If we know we’re not getting something from the database most likely something is going wrong in the model.

Views

The views is where the data is presented to the user. It’s where our HTML, CSS and JavaScript is put to use. We want to give users an easy user experience while looking great this is where we’d dictate those things.

Controller

The controller is exactly what it sounds like, this is where all the logic is supposed to go. It takes in the users input and actions then tells the model and the view to update accordingly. It connects the views to the model.

Analogy

Let’s use an analogy to help understand all the roles of an MVC. Let’s pretend you’re in a restaurant. You tell the waiter your order (user input). The waiter writes down your order then takes it to the kitchen (waiter = controller). The chef then receives your order and starts gather all the ingredients it takes to give you the dish you want (chef = model). The waiter then brings your food back out looking amazing and exactly what you asked for (plate of food = views)! This analogy should helpclear somethings up.

Wrapping Up

MVC is a very useful architecture especially in big applications it helps with separation of concerns and debugging. It’s also helps with quick building of an application because our team of software engineers would know where to look for specific things! I hope this blog helped you understand MVC alittle bit more and you lean towards using it!

--

--