Thursday, April 18, 2019

What is in a name?

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.

Now of course I have explained all of this numerous times. I think many times students are just expecting the system to fill in the blanks for them. It would be nice if the system would. Maybe one day we’ll have artificial intelligence built into development environments that will help with this sort of thing. But we are not there yet.

Our IDEs do a lot for us (developers) that they didn’t do for us back in the day. No autocorrect in punch cards. I know that some educators believe that using a fancy IDE with automatic features is a bad idea. Students should learn without them. They may have something of a point but I resist the idea because I don’t want to make programming to hard. I don’t run a weed out course. Plus these modern tools open the door for students to experiment. Intellisence in Visual Studio lets students see a lot more options then I have time to cover in class.

I keep coming back to naming things though. Selecting meaningful names is important. Making the connection between declaring and defining objects/variables and the names themselves is important.

Spring break started tonight. Figuring out how to address this is something to think on in a couple of days when I’m relaxed.

No comments: