A Adam Learning
Back to notes
9618-AS-12-02Chapter 12Section 12.2short-answer

12.2 Program Design 程序设计简答

Review the exact wording students need for this knowledge point, then open a filtered question list when ready to practise.

Find questions for 9618-AS-12-02

Scope

本页整理 structure chart 与 state-transition diagram 的 purpose、symbols 和 reading。完整绘图及由图写 pseudocode 留到专项。

Structure chart purpose

A structure chart:

  • Shows how a problem/program is decomposed into modules/sub-tasks。
  • Shows module hierarchy and which module calls another。
  • Shows selection and repetition of module calls。
  • Shows parameters/data passed between modules and return values。
  • Can distinguish procedure/function relationships through interface information。

它不显示每一条 algorithm statement 的执行顺序;那是 flowchart/pseudocode 的任务。

Structure chart symbols

  • Rectangle:module/procedure/function。
  • Connecting line:calling relationship/hierarchy。
  • Diamond:selection/decision;one of alternative modules is called at run time。
  • Curved/circular arrow:iteration/repetition;the connected calls are repeated, usually in shown order。
  • Data arrow:parameter passed to a module。
  • Return arrow:function return value;BYREF may be represented bidirectionally according to notation。

Explain 题必须用图中的 module names,例如:

The curved arrow represents iteration: Module-A repeatedly calls Sub-Y1, then Sub-Y2, then Sub-9.

Benefits of modules in design

  • A specific task is isolated as one module。
  • Repeated tasks can be reused/called from several places。
  • Complexity is reduced。
  • Independent testing/debugging and maintenance are easier。
  • Parameters reduce reliance on global variables and make data flow clear。

State-transition diagrams

Document a system whose behaviour depends on its current state and an event/input

  • State:current mode/condition of the system。
  • Transition:directed change from current state to next state。
  • Event/input:causes transition。
  • Output/action:may occur during transition。
  • Self-loop:event occurs but system remains in the same state。
  • Start/initial state and final/halting state may be indicated。

Reading method

  • Begin at stated initial/current state。
  • Follow only the arrow whose event matches the next input。
  • Record any output on that transition。
  • Update current state to the arrow destination。
  • Repeat for each input in order。

For heater example, Temp < 10 changes Off to On;Temp > 20 changes On to Off。Intermediate temperatures use self-loops, avoiding rapid contradictory switching。

Exam checklist

  • Structure chart purpose 是否写 module hierarchy + data/parameters?
  • Diamond 与 curved arrow 是否分别识别 selection/iteration?
  • Explain symbol 是否引用具体 module names?
  • State transition 是否区分 current state、input、output、next state?
  • Arrow direction 与 event label 是否准确?

Structure chart/state-transition diagram 绘制及转 pseudocode 留到专项。

Practice This Knowledge Point

Open the question bank with this knowledge code already filled in. The filtered list will show matching questions for this note.

Open filtered practice
Source questions used