Lesson 2: Giving Good Instructions
About 15-20 minutes -- Screen-free lesson
What You Will Learn
By the end of this lesson, you will be able to:
- Explain why instructions need to be very specific
- Spot instructions that are unclear or missing steps
- Write better, more detailed instructions for everyday tasks
- Understand what "ambiguity" means and why computers cannot handle it
Why Being Specific Matters
In Lesson 1, you learned that computers follow instructions. But here is the tricky part: computers need instructions to be very, very specific. If an instruction is unclear, a computer cannot guess what you meant. It will either do the wrong thing or stop working entirely.
People are good at figuring out what someone probably means, even if the instructions are not perfect. But computers cannot do that. They take everything literally.
Ambiguity: When something could mean more than one thing. Computers cannot handle ambiguity. They need instructions that have only one possible meaning.
An Ambiguous Instruction
Imagine you tell someone: "Draw a big circle."
That sounds simple, right? But think about all the questions that instruction does not answer:
- How big is "big"? As big as a coin? As big as a basketball? As big as the whole page?
- Where should the circle go? In the middle of the page? The top left corner?
- What color should it be?
- Should it be filled in or just an outline?
A person might guess reasonable answers to these questions. A computer cannot.
The Peanut Butter Sandwich Challenge
This is one of the most famous activities for learning about instructions. It is silly, messy, and will teach your child something they will never forget.
Unplugged Activity: Make a Peanut Butter Sandwich
What you need: Bread, peanut butter (or any spread), a butter knife, and a plate. Optional: jelly or jam.
How to play:
- Tell your child: "I am going to be a computer. You need to tell me how to make a peanut butter sandwich. I will do exactly what you say -- nothing more, nothing less."
- Your child gives you instructions, one step at a time.
- You follow each instruction as literally as possible.
The key rule for the parent: Do exactly what the words say, not what you think they mean.
Examples of taking instructions literally:
- "Put the peanut butter on the bread" -- Put the whole jar on top of the bread.
- "Open the bread" -- Try to open the bag by pulling it apart, since they did not say how to open it.
- "Spread the peanut butter" -- Spread it with your hand (they did not say to use a knife!).
- "Put the bread together" -- Stack all the slices on top of each other.
Let your child keep trying to fix their instructions until they finally get it right. The goal is laughter and learning, not a perfect sandwich on the first try!
Talk About It
After the activity, ask your child:
- "What was the hardest part about giving me instructions?"
- "What happened when your instructions were not specific enough?"
- "How is this like giving instructions to a computer?"
The big lesson: computers are just like the parent in this game. They do exactly what you tell them, even if it is not what you meant.
Common Mistakes in Instructions
When people write instructions, they often make the same kinds of mistakes. Learning to spot these mistakes will help you become a better thinker and a better coder.
Mistake 1: Skipping Steps
Bad instructions for drawing a house:
- Draw a square.
- Draw a triangle on top for the roof.
- You are done!
Wait -- what about the door? The windows? Where on the paper should the house go? How big should it be? Many steps are missing.
Mistake 2: Being Too Vague
Bad instruction: "Put some water in the cup."
Better instruction: "Fill the cup with water until the water reaches the line marked on the side."
The word "some" is vague. How much is "some"? A tiny drop? The whole cup? Be specific!
Mistake 3: Wrong Order
Bad instructions for getting dressed:
- Put on your shoes.
- Put on your socks.
- Put on your pants.
Try putting shoes on before socks! These steps are in the wrong order.
Mistake 4: Assuming Knowledge
Bad instruction: "Save the file in the usual place."
A computer does not know what "the usual place" means. It has no memory of what you have done before (unless someone programmed that in). You need to tell it exactly where to save the file.
Practice: Fix These Instructions
Try It: Can You Spot the Problems?
These instructions for brushing your teeth have problems. Can you find them and write better instructions?
- Put toothpaste on the brush.
- Brush your teeth.
- Rinse.
Problems: Step 1 does not say to pick up the toothbrush first or open the toothpaste. Step 2 is too vague (which teeth? how long?). Step 3 does not say what to rinse or how.
Better instructions:
- Pick up your toothbrush with one hand.
- Pick up the toothpaste tube with the other hand.
- Take the cap off the toothpaste.
- Squeeze a pea-sized amount of toothpaste onto the bristles of the toothbrush.
- Put the cap back on the toothpaste and set it down.
- Put the toothbrush in your mouth.
- Brush the front of your top teeth for 15 seconds.
- Brush the front of your bottom teeth for 15 seconds.
- Brush the chewing surfaces of your teeth for 15 seconds.
- Brush the back of all your teeth for 15 seconds.
- Spit the toothpaste into the sink.
- Turn on the water faucet.
- Rinse your toothbrush under the water.
- Cup water in your hands and rinse your mouth.
- Spit the water into the sink.
- Turn off the water faucet.
That is a lot more steps! But now a "computer" could follow these instructions perfectly.
Try It: Fill in the Missing Steps
These instructions for pouring a glass of juice are missing some steps. What is missing?
- Open the refrigerator.
- _______________
- Close the refrigerator.
- _______________
- Open the juice carton.
- Pour juice into the glass until it is three-quarters full.
- _______________
- Put the juice carton back in the refrigerator.
- Open the refrigerator.
- Take out the juice carton.
- Close the refrigerator.
- Get a glass from the cabinet.
- Open the juice carton.
- Pour juice into the glass until it is three-quarters full.
- Close the juice carton.
- Put the juice carton back in the refrigerator.
How This Connects to Coding
Everything you have practiced in this lesson is exactly what programmers do every day. When you write code for a computer, you are writing a list of very specific instructions. If even one instruction is unclear or in the wrong order, the program will not work correctly.
Programmers call mistakes in their code bugs. Many bugs happen because the programmer assumed the computer would understand something that was not clearly spelled out. Just like the peanut butter sandwich game!
Bug: A mistake in a computer program that causes it to do something unexpected or wrong. The word "bug" has been used this way since the 1940s.
Debugging: Finding and fixing bugs in a program. This is one of the most important skills a programmer can have.
Talk About It
Ask your child: "In the peanut butter sandwich game, when I did the wrong thing because your instructions were not clear, were you debugging? What did you do to fix it?" Help them see that they were already thinking like a programmer!
Rules for Writing Good Instructions
Here are four rules that will help you write great instructions, whether for a person or for a computer:
Rule 1: One Step at a Time
Each instruction should describe just one action. Instead of "Open the jar and spread the peanut butter," split it into two steps.
Rule 2: Be Specific
Avoid words like "some," "a little," "over there," or "the usual way." Say exactly what, where, and how much.
Rule 3: Use the Right Order
Think about what needs to happen first. You cannot spread peanut butter before opening the jar.
Rule 4: Do Not Skip Steps
Include every step, even ones that seem obvious. Remember, a computer does not know what is "obvious."
Check Your Understanding
1. What does "ambiguity" mean, and why is it a problem for computers?
2. What are the four rules for writing good instructions?
3. What is a "bug" in programming?
Key Takeaways
- Computers need instructions that are very specific. They cannot guess what you mean.
- Ambiguity (when something could mean more than one thing) causes problems for computers.
- Common instruction mistakes include: skipping steps, being too vague, wrong order, and assuming knowledge.
- Good instructions follow four rules: one step at a time, be specific, use the right order, do not skip steps.
- A bug is a mistake in a program. Debugging is finding and fixing mistakes.
- The peanut butter sandwich challenge shows exactly how computers interpret instructions -- literally!
Ready for More?
Next Lesson
In Lesson 3, you will play the Robot Game! Your parent becomes a robot and you give them instructions to complete fun challenges.
Start Lesson 3