Programming Analogy

Getting Dressed

On days that you have to go to school, your mother and father are behind you in the morning, asking you to wake up, while you keep saying ‘5 more minutes!’ until you realize it is late and you don’t have time to take bath. So, you decide to just wash your face, brush your teeth, and get dressed.  To get dressed, you follow a particular sequence of steps, like the one given below:

  1. Take off the pajamasKid_In_Payjama
  2. Take off the undergarments from the previous day
  3. Wear a fresh pair of undergarmentskid_in_undergarment
  4. Put on the school uniform
  5. Wear accessories such as the belt, tie, and ID card
  6. Wear socks
  7. Wear shoeskid_In_Uniform

Here, as you can see, you followed a set of instructions to complete a task, which is getting dressed (though hastily, and without taking a bath!).

Now, you know that to properly get dressed, you need to follow the order; you won’t wear a fresh pair of undergarments before taking off the previous ones, nor would you put on the uniform first and then wear undergarments (unless you’re Clark Kent!).

Similarly, you must write the program in a particular order so that the computer does the task given to it correctly, and we get the result that we expect.