top of page

The Three-Variable Fallacy

If you're in a coding class, this might just be a valuable lesson for you. If you're a teacher, I'd love your help collecting evidence for (or against) my theory.

My theory is that students in most coding classes have a hard time learning to code not because it's fundamentally difficult (our pilots have demonstrated that 90% of eighth graders, and their teachers, can learn it without difficulty). I don't think because students need to learn "problem solving skills" or "computational thinking."

I suspect it's because the kind of logic used in coding is unfamiliar. The human mind processes information in narrative terms, and a computer program, while it may look like a narrative, uses a very different kind of logic. Once students understand this unfamiliar logic, the biggest barrier is removed.

Unfortunately, since many computer science teachers don't understand this problem (if I'm right about it), and virtually none of the coding education software out there is designed around teaching it, many students end up stuck in the broken world of "narrative coding."

Consider the following program:

var a = 1;

var b = 2;

var c = a + b;

a = 5;

b = 5;

output (c);

What do you think this program will output?

  • 10

  • 55

  • 3

  • a + b

Students, write down your answer before you read any further, and please put it in the poll below when you get there :)

Here's what happens when this program executes:

  1. a is "assigned" the value 1. Think of a as a memory storage space that holds a number: this statement records the number 1 in this box.

  2. b is assigned the value 2. Now we have two boxes holding different numbers.

  3. c is assigned the value 3 (because a + b = 3 at the time this statement runs).

  4. The value in variable a is changed (the new value doesn't matter, it's just there to confuse you).

  5. The value in b is also changed.

  6. The program outputs the value of c, which has not changed since it was assigned in line 3.

I believe that most students are likely to select 10 as their answer. Anecdotally, students I have spoken with often do say this. But I need evidence -- teachers, can you put this question on a quiz in your class, and let me know the results at I need to know:

  • (optionally) Your name and email.

  • What population is in the class?

  • How many hours of instruction before they took the quiz?

  • Before the quiz, what did you predict the answers would be?

Thank you!

What answer did you write down?

  • 10

  • 55

  • 3

  • a + b


bottom of page