liveBook · Manning

Reusable subtask

As explained in Get Programming: Learn to code with Python

A reusable subtask is a task whose steps can be applied with different inputs to produce different outputs.

A reusable subtask is a task whose steps can be used with different inputs to produce different outputs. Instead of creating a separate robot for every warehouse item, create one generic task that can find any requested item. The useful balance is making subtasks small enough to manage but general enough to reuse. section 20.1

When designing a subtask, ask:

Ordering an item online

Break the larger task into smaller tasks such as finding an item, supplying item details, and arranging delivery. Each task can be viewed as a black box: focus on its inputs and outputs without needing every internal step. section 20.1

Figure 20.1. One possible way to divide the task of ordering an item online into smaller, self-contained, and reusable subtasks. Each gray box represents a task. Things to the left of the box are the inputs to a task, and things to the right are outputs of the task.

Follow the diagram to see an online-ordering task divided into self-contained subtasks, with inputs shown before each task and outputs afterward. section 20.1

How Get Programming: Learn to code with Python covers it

How deep it goes
Defines reuse, inputs, outputs, and generic design, but stops short of implementation code.
Examples
Uses warehouse robots, online ordering, and dividing a research paper and presentation into smaller tasks.
What you can do after
Apply task decomposition by identifying reusable steps, their inputs, and their outputs.
How it connects
Connects reusable subtasks with task decomposition, black boxes, inputs, and outputs.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Get Programming: Learn to code with Python. The section links point to the parts of the book it draws on.