MVC Simply Explained
You probably have heard of this MVC before, and wondered what is it. In simple words, it’s a design pattern that makes your code organized, easy to read and most importantly super-fast to debug!
But what those three letters stand for. Well, let me break it down for you. MVC stands for Model, View, Controller. Each one of these serve a specific function. As you know any application consists of several parts. Firstly, the visual part which the user can see and interact with and this is called the View. For example, the view in web development is simply the Html and CSS code.
Then we have what is happening behind the scene. Say that the user visited a flight booking website and wants to get info about a certain flight, like the departure time, dates, price, etc. They will first interact with the view by, probably, clicking on a button to get this info. Once the button is clicked we need some mean that will respond to this and that is called the Controller which will respond to what a user wants and do what needs to be done. In this case the user wants flight info. The controller then turns around and talks to the third part of the application which is the Model. The model is like a storage. It gets info from Database and gives it to the controller. The controller might edit this info then deliver it to the user. Finally, the user will be able to see flight info.
In conclusion, the view does not contact the model directly, instead, it contacts the controller which works as a connection point between the view and the controller. In other words, the controller works a waitress. A waitress takes orders from a customer, turns around and go to the kitchen to get food (Model) to the customer to enjoy!