teacher note Teacher Note: Misconceptions

There is a lot of research evidence that assignment is a difficult topic for students who are first learning to program. In a study of professional graphic designers who had taught themselves to program, the assignment statement was rated the top most difficult programming statement to learn. Why is that?

One reason may be because assignment requires the programmer to be consistent in understanding and predicting what happens in a program. Assignment is always the value on the right gets copied to the space (in the computer’s memory) named by the variable on the left. Researchers at Middlesex University in England found that a critical predictor of success in programming is to see that assignment always does the same thing

How do students get assignment wrong? Here are three ways. One is that they see assignment as being a move of the value (rather than a copy). So, they think that after var1 = var2 the variable var1 has the value from var2 and the variable var2 has a value of nothing or zero.

Click on the right arrow below to play the following video.

A second model, which may be more common, is that they see assignment as a relationship. Once var1 = var2 then any change to var2 will automatically change var1. The problem here is that the student doesn’t see the assignment as an action. If a student doesn’t see the assignment as an action, it’s hard to understand why the ordering of statements is important.

A third problem is that some students have assignment dyslexia, which means that instead of writing the assignment with the variable name on the left side of the = and the value on the right, they reverse it as shown below.

7 = daysInWeek

The computer sees the above assignment statement as an attempt to change what 7 means, and won’t allow it. It will cause an error when you try to run it.

How do we help students get assignments right? Have students trace programs with assignments, where they draw values in boxes. Watch what they do, and try to be aware of their model for how assignment works. If they have one of these other models, try some of the examples in this section – by tracing, and then on the computer. Get students to see where their model doesn’t accurately capture what the computer is doing.

Let’s say that you showed Sam this program:

number2 = 32
number1 = number2
number2 = 17

Then asked Sam, “What’s the value for the variable number1?”

You have attempted of activities on this page