Friday, June 03, 2016

Helping Students Debug Code

It is final project time for my programming students. They are working on projects to show me what they have learned. They are very clever these kids. So clever that sometimes they can’t figure out what the did wrong. That’s were they need me. It’s so good to be needed.

Now there are two basic types of problems. One is syntax problems. The other is logic problems. You’d think they’d be easy to find and fix for an experienced coder like myself. In most cases you would be right. But not it all cases. As I said these kids are clever. They figure things out that I would never ever do. For example they delete things because “I didn’t know what it was for” that the system added automatically and that it needs. I’ve seen a lot of those so in many cases the fix is easy.

In other cases they do something that is new to me. In other cases there are hard to find errors. Missing or extra semi colons are common. At least Visual Studio helps me find some of those. Today a student had a bunch of errors that showed up because a they left a parameter out of a method call. The error messages were no help at all. But experience sure helps.BTW I always make students watch me debug so they can learn how its done. That may be on of the more useful things in the course.

The hardest part of helping students with logic problems is understanding what they are trying to do. I suppose that it is not surprising that they have trouble explaining it to the computer when they have trouble explaining it to another person. This process of thinking about a problem and developing a clear description of what is to be done is hard. They have this idea in their heads but getting it out in a way that doesn’t include magic can be hard. I need to figure out how the help them do this better.

Sometimes students start by asking me the wrong questions. They ask “how do I do [such and such]” referring to a code structure, an object, or some other feature of the libraries or language. Somehow they have decided that will do what they want if only they figure out how it works. Sometimes they are right but not always. Generally I have to ask them what problem they are trying to solve. Often this means I suggest some other way to solve the issue.

This is the old “if all you have is a hammer all your problems look like nails” problem. Students can’t learn everything about a language and its libraries in a few weeks so they try to make all their problems fit the tools they have learned. While I try to assign projects they can do with only the tools that have been covered in class when final projects come around and they have more choices things get different quickly. I think that maybe half the good learning comes in the last week of school when they work on these projects.

Next week the projects have to be done and I get to grade them. I expect to learn a few things in the process. Hopefully my students do as well.

4 comments:

  1. This is a very interesting read. Thank you.

    I am conflicted regarding helping students debug because I feel that there is a thin line between helping and fostering a blind dependency which draws them to office hours. How does one balance that? Any thoughts/ideas?

    ReplyDelete
  2. Yes actually I wrote about this last October http://blog.acthompson.net/2015/10/would-you-like-hint.html

    ReplyDelete
  3. Yes, teaching debugging is very tricky/challenging. For the kids I've worked with, it is such a new skill/thought process--so different from the way that they are used to interacting with world.


    As time goes on, I find it's one of the most important skillsets to foster--it really can help liberate kids from depending on the teacher. ( I still remember spending a good 20 minutes trying to help a kid track down an error that ended up being caused by '1' replacing 'l' in the code editor--was almost indistinguishable in the editor's font!)

    ReplyDelete
  4. It always amazes me how little time textbooks spend on debugging. One brief show and tell of the debugging tools then on to perfection. I spend more time trying to teach debugging than syntax. Syntax the kids can read from the book, debugging take effort and experience from making errors. Simple tricks like print statements to follow variables simply seems to be too much work for some. And again there is that dividing line between helping and dependency.

    ReplyDelete