Structure Diagrams
A structure diagram shows a problem that has been broken down into smaller parts. The whole problem sits in a single box at the top, and everything it is made of sits on the levels underneath.
Each level below the top box holds the subsections of the box directly above it. Any subsection can be broken down again, so the level below that holds its smaller tasks. This carries on until every box is small enough to be written as one sub program or just a few lines of code.
| Position | What it holds |
|---|---|
| Top box | The whole problem |
| Next level down | The main subsections the problem is made of |
| Levels below that | Smaller and smaller tasks belonging to the box above |
The top box is the whole problem, not the first step the program carries out. Nothing here says what happens first, because that is not what the diagram is for.
Boxes are rectangles joined by straight lines, so the shape widens towards the bottom. A line means the lower box is part of the box it is joined to. Boxes are joined only to their parent, never across to each other, so every task can be traced back up to the problem it belongs to.
For example, a program that waters a greenhouse could have Water the plants in the top box. Joined to it on the level below sit Check how dry the soil is and Give the plants a drink. Give the plants a drink is broken down once more, giving Open the valve, Wait 30 seconds and Close the valve on the next level, each joined only to Give the plants a drink.
OCR GCSE Computer Science · Structure Diagrams