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.

In simpler words

A structure chart breaks a big problem into smaller modules. The top box is the whole program. Lines show which module calls which. Small arrows show the data passed down or sent back. A state-transition diagram shows the states a system can be in, and the events that move it from one state to another.

An everyday comparison

A structure chart is like a company chart showing who gives work to whom, with notes showing what papers go down and what reports come back up. It does not show the order of every task in the day. The comparison stops working because a chart can also show selection with a diamond and repetition with a curved arrow, which a company chart does not.

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.

In the exam

When drawing a structure chart, place the main module at the top and sub-modules below, joined by lines. Label each parameter arrow, with a hollow circle for data and a filled circle for a flag, and show its direction. Use a diamond for selection and a curved arrow for iteration. When writing headers from the chart, turn downward arrows into parameters and a single returned value into a function. For a state-transition diagram, label every arrow with its event.

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