How do you teach students about debugging? To have The Debugging Mind-Set? Can they reason about possible causes of incorrect behavior?
For the past year, I have been revising material to help students learn about using gdb to assist in debugging, which is an improvement over the "printf-based" methods previously. And while this approach is usually used when the program has crashed from a segfault, many students are stymied when the problem is incorrect behavior rather than invalid behavior.
When their program crashes, they usually appreciate that gdb can show them what line of code / assembly has crashed. But how can a student "debug" incorrect behavior? Many try the "instructor" debugging method (they try this too when the code is crashing), where they either present their code or describe the basics of what they have done and ask us, as an oracle, what is wrong. I try to offer questions that they need to answer about their code. Sometimes the student follows well and this is valuable guidance for him or her to solve the behavior issue.
Other times I have asked these questions, trying to build up a set of hypotheses to test and investigate, and the student effectively rejects them. Not for being wrong, but for not clearly being the answer. They have the subconscious idea that their code is failing for reason X, which was their intuitive guess (these guesses are a good start). But the idea that they just do not know enough and need to collect more data is not grasped.
You are a doctor when debugging. Sometimes the patient gives clear symptoms. And other times, you need to run more tests. Again, thankfully, usually if an instructor recommends running a certain test, the data gleaned is enough to guide them through the diagnosis. Students appreciate when this happens; however, there is creativity in considering other possibilities and sometimes that possibility requires being open to everything (see TNG Finale).
This semester I am co-teaching Operating Systems. We have told the students that you have to know how to debug, as sometimes printf is what you have to debug. And other times, to quote James Mickens, "I HAVE NO TOOLS BECAUSE I’VE
DESTROYED MY TOOLS WITH MY TOOLS." So in the dystopian, real-world, you need all the debugging tools and techniques you can get.
1 comment:
Post a Comment