- Model: Structures your data in a reliable form and prepares it based on controller’s instructions
- View: Displays data to user in easy-to-understand format, based on the user’s actions
- Controller: Takes in user commands, sends commands to the model for data updates, sends instructions to view to update interface.
To understand the Model , or in general the whole MVC pattern i would like to give you a example of Domino's Pizza shop.
You enter the food court of an extravagant mall, and approach the Domino's counter. Since the counter is already crowded, you wait for your turn to come and as soon as your turn comes or you are the now the first person in queue, you blurt out, “One Margarita with meatballs and extra cheese, please!”
You are the user, and your Pizza order is the user request. To you, the Margarita is just your favorite pizza, and you pretty reliably know that this will be a fluffy with lots of cheese and meatballs.
The pizza boy gives you a quick nod. To the pizza boy, the Margarita is not a special pizza, it is merely a series of steps:
- Remove the pizza dough from the refrigerator
- Stretch and flatten the dough on a floured work surface by using his
fingers
- Dust a pizza peel or baking sheet with a light, even dusting of flour
Add bitters
- Drape the dough over the back of his hand, and then rotate it slowly
Add cherry
- Place the dough onto a pizza peel.
- Spread the sauce evenly over the dough
- Sprinkle grated cheese evenly over the sauce.
- Add meatballs, and bake it.
- Ask for credit card and charge.
The pizza boy's brain is the controller. As soon as you say the word
“Margarita” in a language that he understand, the work begins.
This work is similar in nature to making a Calzone or Neapolitan
pizza, but uses distinct ingredients that will never be confused.
The pizza boy can only use the tools and resources that are behind the
bar. This limited tool set is the model, and includes the following:
- pizza boy’s hands
- dough
- oil
- Meat
- cheese
- Heat oven
Perhaps in future, they might have a robot assistant! Or an automatic pizza maker. It does not matter to your particular pizza boy, who can only use the available resources.
Finally, the finished pizza that you can see and consume is the view.
The view is built out of the limited options from the model, and
arranged and transmitted via the controller (that is, the pizza boy’s
brain).