Rocket wrote a function named x. "What does x do?" Raven asks. Rocket thinks hard. "I forgot!"
Raven smiles. "What do you notice? A good name tells you what is inside."
Nova says, "A name hides the steps but shows the big idea. Big ideas can stack in layers too." Let's help them pick good names and build layers.
When we name a function (like make_toast()), we hide all the steps inside the name. That's abstraction at work.
For each, circle the better function name.
These steps are getting ready for bed. Group them under one good function name.
put on pajamas
brush teeth
pick a book
turn off the big light
function name: __________________ Abstractions can stack. Read the layered plan.
MAKE PIZZA (top, big idea)
ββ make_dough()
ββ mix(flour, water, yeast)
ββ stir(20 times)
ββ add_sauce()
ββ add_toppings()
ββ bake(oven_temp=400, minutes=15) Make a layered plan for: WALKING THE DOG. Add at least 3 layers.
| Statement | True or false? |
|---|---|
| A good function name tells the big idea. | ? |
| Layers can stack, one inside another. | ? |
| The top layer has the most detail. | ? |
| walk_the_dog() could hide put on leash and open door. | ? |