Monday, November 27, 2017

A Rose By Any Other Name Gives An Error

There is an old computer science joke that goes more or less like this:

There are two hard things in Computer Science: cache invalidation, naming things, and off-by-one errors

Now I don’t have to cover cache invalidation in my high school courses and I do see an awful lot of off-by-one errors from students but today I’m thinking a lot about names. Names and how students  get them wrong.

Today I had students write code along with me as I demonstrated in on the board. As usual with any GUI interface the first thing I did was draw objects on the form and name them. I’m pretty careful about giving each item a meaningful name. I spend some time talking about why we do that. OF course a larger group of students than I’d like skips that step.

Next I write the code behind being very careful to use the correct names for the objects that I am requesting information from or sending information to. I talk about how having meaningful names here makes like easier. Students diligently copy the code. Anyone experienced with students knows what happens next.

Students insist they did exactly what I did get build errors. Remember how I said some of them don’t name things the way I show them to name them? Yep, this is where they expect the computer to do what them mean even if that isn’t what they told it to do.

Others have the right names but for the wrong objects. “Mr Thompson, why did that show up here and not their?” Answer: Because that is where you told it to display. Try as I might students take a while to understand how important getting the names right really is.

Somehow getting this right is a struggle for some students. I want to believe it is all their fault – they were not paying attention. That has to be it right? But maybe not. Maybe it’s me. Clearly I need a better way of explaining things.  Maybe visual aides? Boxes with names on them? Something. Figuring this out before the next class starts is a priority.

Suggestions are welcome. What works for others?

1 comment:

Garth said...

It does not help that most programming teachers like us are a bit anal and have learned that attention to detail is critical. Most high school students are definitely not anal and attention to detail makes absolutely no sense to them. Personally I think there is no solution for some students. They are doomed in a programming class. Others have the mental maturity to develop attention to detail or their parents have taught it to them. I did not get attention to detail until Marine boot camp. It was forced on me and I kept it. The solution? Physical exercise as punishment until they get it right. Admittedly there might be some resistance to the method but it does work. And they would be the buffest programming class in the state.