What is an MVC framework?

Alex Davis
2 min readMay 31, 2022

Enter — Phase 4!

Ruby on Rails, full-stack applications, and the beginning of all things computer science. In that spirit, I have chosen to discuss the MVC framework for this blog post.

MVC, or Model-View-Controller, is a software design pattern or framework. It is commonly used to implement user interfaces, data, and controlling logic. Rails was created with the MVC architecture in mind, so understanding it was critical to successfully building Ruby on Rails applications.

So- what is the MVC framework?

Photo credit

First, let’s discuss the model, which is responsible for handling the critical aspects of an application. In other words, the model files are where our application’s logic lives. This can mean communicating with the database via Active Record or implementing and expressing custom algorithms. Models are typically connected one-to-one with an underlying database table. They are the central component of the application.

Next is the controller. The controller’s job is to connect the models to the view. It transmits data requests from the user to the model and then delivers rendered data in the view to the user. It will also update the model and/or view in response to user inputs. The controller can do this through CRUD methods, such as index, create, show, update, and destroy.

And finally, the view. The view defines how our data is presented to the user. Then, it renders that information when it is delivered from the controller. Therefore, it should contain the least amount of logic out of the MVC. Thus far, the view I am familiar with has been a React frontend.

Confused yet? You’re not alone!

Thankfully Flatiron School gave an excellent, real-world example:

Let’s think of each of these components as pieces of a restaurant. We have a chef, a waiter, and a table in our restaurant. For instance, the chef is the model because they manage all of the essential aspects of eating out, such as making the food for our customers. The waiter is the controller because they are responsible for taking the food from the chef and delivering it to the table for the customer. And finally, the table is the view. The table doesn’t do anything besides sit there and hold the food, which is what the view does with our data!

The MVC framework is a handy tool for building full-stack applications. It was one of the first computer science topics we learned at the Flatiron School. Now, onto algorithms and data structures! :)

--

--