A nonleaf function pursues one broader, clearly defined goal by coordinating multiple operations and usually calling other functions. Examples include updating game graphics or collecting and sanitizing user input. section 3.6.1
Design a useful nonleaf function by:
- Giving it one particular goal rather than an assortment of unrelated tasks. section 3.6.1
- Defining its behavior precisely; vague or subjective goals need clearer inputs, parameters, and outputs. section 3.6.1
- Splitting complex work into smaller functions, then implementing leaf functions before the nonleaf functions that depend on them. section 7.7
Finding and removing a list value
Finding the largest value and removing it combines two operations. Make separate functions for finding and removing, then use a nonleaf function to coordinate them when the combined task recurs. section 3.6.2
