Monday, December 15, 2008


I have been studying about the evolution of computer programming languages lately. I thought it might be fun to make a flow chart that most programmers make for complex programs with many subroutines and apply it to something everyone(or almost everyone does) almost every week or sooner.

I thought I would do an informal flowchart for shopping for food and break it into three subroutines: checking the fridge for what we need, second driving our car to the market and three shopping for the food at the market. usually yes no answers are represent by zero or 1 on the binary level. depending upon the language yes is usually 1 and no is zero.

Theoretically, if we had our own robot we could program him, her or it to do this for us or do it ourselves.

informal flowchart for shopping for food

first subroutine checking fridge for what we need

walk to the fridge

open the door

do we need? milk yes or no
cheese yes or no
bread yes or no
eggs yes or no
butter yes or no
Let us presuppose the answers to all these questions are yes

second subroutine
Shall we go now to the market and buy these items? yes or no

shall we walk yes or no
shall we bike yes or no
shall we drive yes or no

Let us presuppose the first two answers were no and the last yes and that the answer to shall we go to the market now was yes

Third subroutine
driving to the market
open the front door? yes or no
walk down the steps? yes or no
walk to the car? yes or no
is there a garage? yes or no
If then no garage get in the car? yes or no

Is the car open yes or no
if no then get keys yes or no
put key in door yes or no
did car start yes or no
if yes then let it warm up a minute so engine lasts longer
If car started then is it a stick shift or automatic?
If automatic place foot on brake and put into reverse?
Look out rear window. is there traffic? yes or no
If traffic then wait until it clears.
If no traffic then proceed back a little
Then put into drive and move forward.

(to simplify) drive to market.

next subroutine (park)
next subroutine (get out and go into market)
next subroutine search market shelves for items
next subroutine buy items found
next subroutine push kart to car
next subroutine unload basket into car
next subroutine drive home and park
next subroutine get out and unload items out of car and into refrigerator.

As you can see this kind of flowchart would be constructed before writing a complex program in any language to make sure no step is left out. after writing the program the programmer would then debug the program. He or she would make sure the program not only didn't have any infinite loops that waste both time and energy and make sure it didn't stop unexpectedly and performed consistently doing what he or she wants it to do no matter how many thousands or millions of times the program is executed by the computer or robotic device.

No comments: