MVC design pattern

Bryan Rhodunda
2 min readMar 10, 2020

why do developer use model view controller?

Most companies and developer use design patterns to make their code less complicated and easier to work with. The most popular design pattern is MVC also known as model view controller. The MVC design pattern helps developers split their code into chucks so it’s easier to work with. This is important because when other engineers look back at your code they can see how you wrote it. Which in turn makes it easy to work with and debug

MVC diagram

Model

The model contains all of the logic for the application. This includes all the data for your program like databases files ect.

View

The view contains everything the user can see. This includes text, buttons, and anything else in the window.

Controller

A controller updates both the model and view. It accepts inputs and performs the corresponding update.

how does MVC work?

When a user is interacting with a website their request go’s to the controller. The controller interprets the request and get the data that the request need from the model. The models job is to handle the applications logic and interact with the database. The model handles all the CRUD operation. This mean the controller never needs to worry about the data that it sent or received. Also, the model does not need to to deal with the users request. The controller tells the model what to do.

After the controller interacts with the model and gets the data that it needs. It then interacts with the view so it knows how to displace the data that it got from the model. The views job is to handle presenting the data. After that the view figures out how to present the data. after the view figures out how to present the data it sends it back to the controller. Following that the controller presents the data to the user. It’s important to note the model and the view don’t interact with each other.

--

--