Can you talk a little about why you think the cooking analogy is flawed, and why you think it’s still alluring for people to use as an analogy?
I’ll address your questions in reverse. Educators like the analogy, because they feel that it is accessible to most students. The demonstrations are usually fun and comedic, and students remember them. Educators generally use the cooking analogy to demonstrate how to make a good algorithm, but I think it merely confuses students regarding levels of specificity (students get hyper specific and then have more trouble with abstraction). If anything, I would use it as an example of how not to create an algorithm. However, since lots of educators use it to demonstrate ‘good’ algorithms, I merely avoid the concept entirely.
Cooking ‘algorithms’ are quite often ambiguous to their intended audience (humans). Their pre- and post-conditions are (in general) ill-defined, and their timings and looping conditions are flexible or ambiguous (you often see phrases like “timings and temperatures may vary” or “stir until smooth”). Every bit of this is antithetical to the vocabulary and thinking we want students to move towards. The saving aspect of the cooking example is the definition of a pre-condition, post-condition, and, perhaps, why we don’t use a natural language for programming.
Can you also talk a little bit about the exercise you use to demonstrate why we have programming languages?
I use an exercise with balloons (if latex is prohibited, I use spheres). The goal of the exercise to demonstrate why natural languages are not “good enough” for humans let alone digital computers.
(0) Students are broken up into pairs. Each pair is given two balloons of the same color and one permanent ink pen (Sharpie).
(1) Students are told to blow their balloons up and tie them off so that the balloons are of “equal size.” At this point, students ask for clarification because of “ambiguity.” I simply tell them that they need to be the “same.” After all, the point of the exercise is show where ambiguity happens.
(2) Students are told to get back-to-back holding their balloons, and one person should be holding the pen. The person with the pen is Person 1, and the other is Person 2. (I harken back to this point later when talking about variables).
(3) Instruction: “Person 1 – Draw an X on your ballon.” Students ask for clarification, and I simply tell them to draw the X “however you wish.” I then tell Person 1 to hand the pen to Person 2. Students are to remain back-to-back.
(4) Instruction: “Person 2 – You are not allowed to make any noise, vibrate your body, or provide feedback. Person 1 – Without looking, verbally explain to Person 2 where to draw the X on their ballon so that the X is the same size, same boldness, and at the same angle as yours.”
I then repeat the exercise with Person 2 drawing an O, but Person 1 can provide feedback. Students are then asked to compare balloons (Spoiler Alert: They’re never the same). Students will claim that they’re “close,” but that’s not good enough. We then have a discussion about the words used. Common wording used:
( a ) “the top of the balloon” – What is the “top?” How did we agree on that?
( b ) “make the X the size of your pinky finger” – Because everyone has the same size pinky finger…
( c ) “make the O one inch (or centimeter) in diameter” – This one is fun, because students think they’re being smart by being hyper specific. However, when I get two students up to a board to draw a one-inch line, they are never equal (I don’t really care that they’re not one inch either).
( d ) “the line is very thin” – Really? How thin?
From here we have a discussion about measurements and common understandings. I point out that they could have used the pen cap as a measurement device, because it’s something that both sides have in common. Once students understand the need for specific words and common understanding, I turn to my second exercise, The Human Robot, to help with abstraction and computational thinking with a common vocabulary.
Note: I have done this exercise where I tell students ahead of time what we will do, and then give them two minutes to plan. The results are always the same (as in, the balloons are not).
Note 2: There are plenty of variations on this exercise. I have seen educators use random drawings where students write down instructions and another group attempts to follow them. This works well also, and I do this if I have time. However, in every case, the point is to demonstrate why natural languages (English in my case) are horrid for getting repeatable, specific algorithms.
I apologize for the length of this post, but I needed to be verbose to get my opinion solidified.