Grade 7 Computer Science · What a program is

Common mistakes about programs

Six mistakes, most of them attributing an intention the machine does not have.

One mistake, six disguises

“The program ran with no error, so it is correct.” “I checked it on an example, so it works.” Both sound reasonable, and both are wrong for the same reason. Spot the reason and you will spot the other four mistakes too.

Almost every beginner’s mistake in this unit is the same mistake in different clothing: assuming the computer understands. Every item on the list is one of its appearances.

Example 1 — correcting “it runs without an error so it is right”

  1. A claim: there is no error message, so all is well.
  2. Ask: what was the result supposed to be?
  3. Compare with the result actually obtained.
  4. An absence of an error is not proof of correctness.

Example 2 — correcting “it works on my example”

  1. A claim: I checked and the result is right.
  2. Ask: on which example exactly?
  3. Run it on an empty list and on a single item.
  4. Usually one of them breaks the program.
A scenario: The average that worked on the example — at each step a course of action is chosen and its consequence shown; 5 possible situations.