Live data from Hacker News

Why don't schools teach debugging? (2014)

danluu.com

21–30 of 174 posts

Re: Why don't schools teach debugging? (2014)

#21

I imagine it would be quite hard to come up with good debugging examples for a class. Anything that has one right answer is going to smell like a made-up classroom assignment. The thing that makes debugging hard is multiple hypotheses (or amazingly, exhausting all hypotheses). Your crash can be caused by errors on many different abstraction levels, so your debugging process has to be thought about on many levels. On…

These are unskilled programmers, so shouldn't it be ok to start out really simple?

Have bugs with index bugs like:

    for(var i = 1; i 
i.e. Find out why it's not showing all the items (i = 1 instead of 0), find out what's going on with the formatting of the lastname (there's an extra space at the beginning of the name).

For SQL use a JOIN where it needs a LEFT JOIN.

I can think of others off the top of my head. Leave out an optional parameter that's been populated from the front-end, but don't pass it to the method call. In OO languages, have a constructor accidentally call itself instead of the alternative with more parameters (infinite loop). Nest two for loops and accidentally use i instead of j inside the inner loop. Have an if statement that looks sorta right but is logically impossible to satisfy.

For the "only sometimes crashes" bugs, div by zero is an easy example.

All the sort of accidents you instinctively correct now are probably good beginner debugger exercises.

Re: Why don't schools teach debugging? (2014)

#24
My first encounter with programming for engineers was in college with already antiquated machines running Unix (in 2001-2002), and with a professor requiring us to use some basic text editor and debugging by printf. It put me off from programming for several years before I came back to it with higher level languages (VBA then .net) and rich IDE (the excellent Visual Studio).

The IDE (and debugging experience) is as important if not more than the language in my opinion.

Re: Why don't schools teach debugging? (2014)

#25
post #4

This can really be extended to basic troubleshooting skills, and goes beyond software development -- beyond technology, even. Troubleshooting is really just a special application of general 'problem solving', which is something schools aim to teach. I'm not sure why troubleshooting skills are not taught, especially something like "divide and conquer" [1]. Even in very complex systems, so long as you have the right ac…

I wanted to write something similar, so I just upvoted you and piggybacked here. "Debugging" is really a subset of "Problem Solving". My grandfather had (by today's standards) very poor schooling, but he taught me some PHYSICAL WORLD DEBUGGING techniques which proved useful later in life. Just one simple example (I suppose this would be "Tracing" in IT) - once he was working on a cabinet that had somehow warped and wouldn't close properly. His solution: he cleaned the door and the frame, dipped his finger in oil and smeared it along the side of the door that would touch the frame. Then closed the door and opened it again - the point were some trace of oil was visible on the frame was the one that needed to be pared down to allow the door to close.

He also used intuitively divide&conquer to find faults or leaks in wirings and pipes and so on.

It is really something that should get more study and practice outside of IT or science, and I am sure that mechanics and other craftsmen have their own set of algorithms that can be used in various situations.

Re: Why don't schools teach debugging? (2014)

#28
They don't teach you unit test either. Or how to read a doc efficiently. Or how to make a technical choice. Or how to conduct a meeting. Or how to direct a project.

At best they'll talk about best practice and will give you an exercice that implies you should use one of those skills.

The amount of useful stuff that are not taugh in school is enormous.

Re: Why don't schools teach debugging? (2014)

#29
One of my clearest and earliest memories of programming as a child is of having a working program, making a few changes, and suddenly nothing worked, being totally lost in the woods as I randomly tried fixing stuff and got absolutely nowhere. I feel like it's had a big impact on my approach to programming ever since, trying to break things down into manageable pieces rather than one big ball of mud that's fragile to errors.

Re: Why don't schools teach debugging? (2014)

#30
The problem with teaching debugging that I see is that I am not aware of any systematic course for debugging available with suitable exercises, systematic theory etc.

If there were, I can believe some universities might at least be interested in offering an optional course.

Post reply on HN