What does decomposition mean?
Breaking a problem into smaller parts that are easier to solve, then solving each part. Writing one function per part is decomposition in code.
In a lesson
Decompose the whole brief into functions:
patrol(stop_at)must return the number of steps, andgo_home(steps)must bring the robot back. After arriving (LED green), drive home and printsteps each way: <n>. The robot must end near where it started.
Learn it
- Taught in F4.6 Project: the patrol Functions and structured code, GCSE
Used in
- F4.1 Writing functions
- F4.4 Decomposition and abstraction
- F5.1 What an algorithm is
- F6.7 Project: the fail-safe controller
- A1.4 Subroutines, parameters and passing by reference
- A2.6 Decomposition, composition and automation
- A2.9 Computational methods
- A2.10 Project: out of the dead end
- A10.9 Project: a tiny robot operating system
- A13.8 Project: the way out
and 2 more lessons.
Do the lesson in the simulator