Avoid using x and y as variable names to prevent students from confusing variable assignments with mathematical expressions.

  • 4 = x and x = 4 are both valid mathematical expressions; however, variable assignment is only of the form variable = value/object.
  • Because x and y (as well as z, a, b, and c) are common variable names in math problems and they are joined to a value by a sign (=) used in both math and computer science, students may be misled into believing that variable assignment and mathematical expressions have the same properties and are interchangeable.
  • Suggest variable names that describe properties of the variable, such as what information it contains or what it will be used for.
  • Using descriptive variable names may prove useful in helping students understand the differences between variable assignment and math expressions and may encourage the common practice of using descriptive variable names that make debugging easier.
External Source: 

"Visual program simulation in introductory programming education" by Juha Sorva, from §5.4.2: Students Struggle to Form Good Mental Models of Notional Machines

Other Tips By: