Skip to content
Tactiverge

School/◇ Explorer/Week 17

Flowcharts: drawing a decision

Engineers often draw a machine's 'brain' before writing a single line of code. What does that drawing look like?

About 30 min · 3 goals · Checked by automated tests; not yet reviewed by an educator

1.Why should I care?

A flowchart lets a whole team (engineers, clients, testers) see a machine's decisions at a glance and spot missing cases before anything is built. It's the bridge between a client's words and working code.

  • ◇ Read and draw flowcharts using start/end, process and decision shapes.
  • ◇ Count the different paths through a flowchart.
  • ◇ Test a flowchart by choosing inputs that follow every path.

2.Predict

The smart fan's flowchart asks up to three yes/no questions and can end in OFF, LOW or HIGH. How many different paths are there from start to finish?

Guess first. Being wrong here is how the surprise works.

3.Discover

Your job is tester. Choose inputs that send the fan down all four paths, ticking each off in the test log. What is the fewest number of runs that can test every path?

Smart fan decision runner

A machine decides by asking yes/no questions in order. Set the sensors, then run the flowchart one step at a time. A good engineer tests every path, not just one.

Someone in the room?

Window open?

  1. Start: read the sensors
  2. ◇ Is someone in the room?yes
  3. ◇ Is it hotter than 26 °C?yes
  4. ◇ Is the window open?no
  5. Fan HIGH
  • ○ nobody home → OFF
  • ○ cool enough → OFF
  • ○ hot, window open → LOW
  • ○ hot, window shut → HIGH

Path: Is someone in the room? yes → Is it hotter than 26 °C? yes → Is the window open? no → fan HIGH. Paths tested: 0 of 4.

Can't use the interactive? Read a description instead

The decision runner lists the fan's flowchart steps and a test log of its four paths: nobody home → OFF; cool enough → OFF; hot, window open → LOW; hot, window shut → HIGH. Each run through the flowchart ticks off the path it took, so you can see which paths still need testing.

4.Watch

→ Watch for how an algorithm is a sequence of steps and decisions, the same thing a flowchart draws.

Shows how a step-by-step recipe of decisions and repeats lets a machine solve a problem such as sorting.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

5.Understand

Three shapes

  • Rounded box (terminator): start or end.
  • Rectangle (process): do something, like 'read the sensors' or 'turn the fan on'.
  • Diamond (decision): a yes/no question with two arrows out, one labelled yes and one no.

Arrows show the order. Follow them with your finger and you're running the machine's program by hand.

Paths, not just outcomes

Each decision splits the path in two. A path is one complete route from start to end. Different paths can reach the same outcome (two ways to get OFF), and a good test plan tries every path, not just every outcome, because a mistake can hide on a path you never walked.

Loops: going round again

A real controller doesn't stop at 'end'. An arrow goes back to 'read the sensors', so the machine checks again and again. That's a loop. In the next lesson, you'll see machines that also remember where they are in a sequence.

Explain it another way

A flowchart is like a 'choose your own adventure' book: each diamond is a page that says 'if yes, turn to page 12; if no, turn to page 20.'

Worked example 1

Design inputs that test each fan path once.

  1. Nobody in the room (any temperature): OFF. 2. Someone in, 22 °C: OFF. 3. Someone in, 30 °C, window open: LOW. 4. Someone in, 30 °C, window shut: HIGH. Four runs cover all four paths.

Common mix-ups

  • If every outcome has been seen, the flowchart is fully tested.
    ✓ Different paths can lead to the same outcome. Test every path.

6.Practice

Practice, not a test. Wrong answers get a hint and another try.

Practice 1

Which flowchart shape holds a yes/no question?

Practice 2

A flowchart asks two yes/no questions one after the other, and every answer leads on to the next question (no early exits). How many paths are there?

paths

Practice 3

A flowchart asks Q1. If 'no', it ends. If 'yes', it asks Q2, which ends either way. How many paths are there?

paths

Practice 4

A tester ran the fan three times and got OFF, LOW and HIGH. Have they tested every path?

Practice 5 · a fresh version every time

A smart fan follows this rule: IF someone is home AND the temperature is above 28 °C, THEN fan on (1), ELSE fan off (0). Someone is home and it is 28 °C. What does the fan do (1 or 0)?

7.Apply it

Draw a flowchart for an automatic school-bag checker: is it a school day? Is it PE day (then check for kit)? Is it raining (then check for a coat)? Count its paths and write one test for each.

8.Reflect

Concepts: Decisions and loops · Testing and debugging · Algorithms, searching and complexity