Program design

Computer Science AS · Software development. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science AS topics

The idea

A structure chart shows how a problem is decomposed into modules. The top box is the whole program and the boxes below it are the sub-tasks. A line joining two boxes means that the upper module calls the lower one. Small arrows beside the line show the parameters: an arrow pointing down is data passed to the lower module, and an arrow pointing up is data passed back.

The chart leads straight to the module headers. Values going down become parameters. One value coming back up suggests a function that returns it.

A state-transition diagram shows the states a system can be in and the events that move it from one state to another.

Rules to remember

Common mistake

Reading a structure chart as if it were a flowchart. It shows which module calls which and what is passed between them, not the order of every statement.

Worked example

A media player has three states. In Stopped, "play" moves to Playing. In Playing, "pause" moves to Paused and "stop" moves to Stopped. In Paused, "play" moves to Playing and "stop" moves to Stopped. Any other event leaves the state unchanged. The player starts in Stopped and the events are: play, pause, pause, play, stop. What is the final state?

  1. play: Stopped → Playing. pause: Playing → Paused.
  2. pause: there is no pause transition from Paused, so the state stays Paused.
  3. play: Paused → Playing. stop: Playing → Stopped.

Answer: Stopped (the state changed 4 times)

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

← Program development life cycleProgram testing and maintenance →Take a Computer Science AS test