Program design tools
| English | Chinese | Pinyin |
|---|---|---|
| structure chart | 结构图 | jié gòu tú |
| state-transition diagram | 状态转换图 | zhuàng tài zhuǎn huàn tú |
| decomposition | 分解 | fēn jiě |
| top-down design | 自顶向下设计 | zì dǐng xiàng xià shè jì |
Planning before you code
- 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.
Software process lab
Classify development examples by the stage or tool they belong to.
Breaking a problem into modules from the top down is called:
Top-down design produces a modular solution.
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.
A flowchart plans a program's logic during the design stage.
A structure chart shows:
A structure chart is the hierarchical breakdown into modules, with parameters down and results up.
Match each design tool to what it shows.
Each tool views the design differently — structure (modules), behaviour (states), flow (flowchart) or steps (pseudocode).
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?").

A structure chart: modules with the parameters passed between them
A state-transition diagram shows:
States are circles; transitions are event-labelled arrows. Ideal for vending machines, locks, traffic lights.
A state-transition diagram makes missing or unhandled transitions easy to spot, because every state and the events between them are laid out.
Seeing every state and event reveals cases you have not handled — e.g. an unexpected second coin in a vending machine.
Top-down design 自顶向下设计
- Top-down (stepwise) design breaks a big problem into smaller sub-problems.
- Each sub-problem becomes a module, making the program easier to write and test.
- A structure chart or state-transition diagram can be turned into equivalent pseudocode.

Black-box tests the specification; white-box tests the code paths
You've got it
- 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