liveBook · Manning

Subtask

As explained in Get Programming: Learn to code with Python

A subtask is a smaller task that forms part of a larger computational or organizational task.

A subtask is a smaller task that contributes to a larger task. Breaking work into subtasks makes separate responsibilities easier to understand and assign. section 20.1

A useful subtask has clear relationships with the surrounding work:

  • Depends on earlier subtasks when it needs their outputs before it can begin. section 20.1
  • Runs independently when it does not need another subtask’s work and can happen at the same time. section 20.1
  • Hides unnecessary details behind a simple task description, while exposing needed inputs and outputs. section 20.1
  • Can live in its own module environment, keeping created items separate unless information is explicitly passed through inputs or outputs. section 20.3

Ordering an item online

One large task becomes several subtasks: place the order, extract its details, find the item, make a shipping label, pack the item, and send it. Finding the item and making the label are independent; sending depends on both packing and labeling. The overall process can therefore be understood through each subtask without knowing every behind-the-scenes detail. 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.

Use the task diagram to trace each subtask’s inputs, outputs, and position in the larger ordering process. section 20.1

How Get Programming: Learn to code with Python covers it

How deep it goes
Explains decomposition, dependencies, abstraction, and module environments, then stops short of detailed code examples.
Examples
Uses online ordering, group research, and document similarity to illustrate decomposition and information sharing.
What you can do after
Build it from scratch by dividing a document-similarity problem into modules or Python functions.
How it connects
Connects subtasks with task dependence, task independence, abstraction, modules, inputs, outputs, and functions.

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.