Program design tools
Design tools
- Before coding, designers draw the program's structure.
- Two key tools: the structure chart and the state-transition diagram.
- Both make the design clear and reveal gaps before any code is written.
Structure charts
- A structure chart shows the hierarchical decomposition of a program into modules (subroutines).
- Each module is a rectangle; lines link a caller (above) to its callees (below).
- Small arrows show parameters passed down and results returned up — so you can read the subroutine signatures off it.
- It's a design-stage tool that captures how the program is broken into parts.
Practice
A structure chart shows:
A structure chart is the hierarchical breakdown into modules, with parameters down and results up.
Practice
On a structure chart, the small arrows on the links represent:
The arrows show data flowing between modules — parameters down to a callee, results back up.
State-transition diagrams
- A state-transition diagram shows the states a system can be in and the events that move it between them.
- Each state is a circle; each transition is an arrow labelled with its event.
- Great for vending machines, traffic lights, locks and user interfaces.
- It makes missing transitions easy to spot ("what if a second coin is inserted while awaiting selection?").
Practice
A state-transition diagram shows:
States are circles; transitions are event-labelled arrows. Ideal for vending machines, locks, traffic lights.
Practice
A benefit of drawing a state-transition diagram is that it:
Laying out every state and event reveals cases you have not handled (e.g. an unexpected second input).
You've got it
Key idea
- a structure chart shows the module hierarchy and the parameters/results passed between them
- a state-transition diagram shows states (circles) and the events (arrows) between them
- structure charts capture decomposition; state diagrams capture behaviour
- state diagrams reveal missing transitions before coding