Break the Picture into Parts
Computational thinking starts with one honest admission: nobody can write a whole complicated program in one go. What you can do is break the problem into parts small enough to hold in your head, solve each one, and let the names carry the meaning.
π‘ The idea
Decomposition: split a problem you cannot solve into parts you can.
- Decomposition means splitting a problem into smaller, independent parts.
- A part is the right size when you can test it on its own in a few seconds.
- Naming a part is real work: the name is the interface everyone reads.
- Solve the parts in any order you like, then compose them at the end.
- The same habit works for essays, experiments and school projects, not just code.
π Words to know
- decomposition
- splitting a problem into smaller parts
- abstraction
- hiding the details behind a name
- compose
- join the finished parts into the whole
π Watch this
One part of a robot, written as a block called body. Nothing else exists yet, and that is the point.
# step one: name one part and nothing else to body square 60 end body
βοΈ Your turn
- Run it, and notice how little it does. That is a healthy first version.
- On paper, list every part your robot needs: body, head, arms, legs.
- Write a second block for the head and test it on its own.
- Decide the join: where does the head sit relative to the body?
- Call the two blocks one after the other and check the join is right.
π― Challenge: Split a flower into two parts, stem and bloom, write a block for each, then draw the whole flower by calling them in order.
Show me one answer
to stem colour green width 5 forward 110 end to bloom colour pink repeat 6 [ forward 24 dot 20 back 24 right 60 ] end stem bloom
Your program