Task decomposition divides a large, underspecified problem into smaller, well-defined subproblems. Each subproblem becomes a manageable function, helping people control complexity, test behavior, and work effectively with AI coding tools. section 3.1 section 7.1
Use top-down design to turn an intimidating program into an organized set of solvable tasks:
- Start with the overall problem and identify its major subtasks. section 7.1
- Split any subtask that remains too large into smaller sub-subtasks until each task is simple enough for a focused function. section 7.1
- Define each function’s inputs, return value, and single responsibility. section 3.8
- Implement leaf functions first, then build functions that depend on them. section 7.7
- Test every function with different inputs before relying on the larger program. section 3.8
Building a spelling-suggestions program
Instead of asking an AI assistant to create an entire spellchecker, define a main spell_check function and decompose its work. get_spelling_suggestions can create a word list, generate all possible edited words, filter those that are real words, and return unique suggestions. The generation step can split further into add_letter, delete_letter, and change_letter. Implementing the smallest functions first makes the larger functions easier for the assistant to write, test, and assemble. section 7.5 section 7.6 section 7.7.8
Figure 7.3 Functions diagram showing the three subtasks of get_spelling_suggestions
A function diagram makes the hierarchy visible, showing how get_spelling_suggestions delegates work to smaller spelling-related subtasks. section 7.5









