MVC Example

Lesson Progress
0% Complete

MVC Examples

Let’s see Model View Controller from daily life:

Example 1:

  • Let’s assume you go to a restaurant. You will not go to the kitchen and prepare food which you can surely do at your home. Instead, you just go there and wait for the waiter to come on.
  • Now the waiter comes to you, and you just order the food. The waiter doesn’t know who you are and what you want he just written down the detail of your food order.
  • Then, the waiter moves to the kitchen. In the kitchen waiter not prepare your food.
  • The cook prepares your food. The waiter is given your order to him along with your table number.
  • Cook then prepared food for you. He uses ingredients to cooks the food. Let’s assume that your order a vegetable sandwich. Then he needs bread, tomato, potato, capsicum, onion, bit, cheese, etc. which he sources from the refrigerator
  • Cook final hand over the food to the waiter. Now it is the job of the waiter to moves this food outside the kitchen.
  • Now waiter knows which food you have ordered and how they are served.

In this case,

View= You
Waiter= Controller
Cook= Model
Refrigerator= Data