It’s been said that the three hardest things in programming are naming things and off by one errors. For some reason, this semester, my students are having the most trouble with naming things. Specifically, they seem to have trouble making the connection between names and objects.
For example, they will use the name of what looks like a text box but without actually instantiating the text box firs Or they will use a different name for the textbox than the name the textbox actually has. And they’ll be surprised at getting an error message that says “the name ‘x’ does not exist in the current context.” The same is true with undeclared variables. Often this is caused by not paying attention. I will set the name of an object while live coding and then use that name later in the code. If they were not paying attention any of the three times I point out the name declaration they may not use the same name in their own code but expect it to work later. After all, it worked when Mr. Thompson did it.
Read More