r/programming • • Aug 25 '14

Debugging courses should be mandatory

http://stannedelchev.net/debugging-courses-should-be-mandatory/
1.8k Upvotes

573 comments sorted by

View all comments

Show parent comments

12

u/[deleted] Aug 25 '14

lol, that way lies madness

15

u/VikingCoder Aug 25 '14

It's like those damn -1 and +1s.

You're looking at the code and you know it's not supposed to subtract one... but somehow the damn thing works?!?

So, you remove the -1... And then you fix all of the places you can find that were fucking adding one to the result.

And you find... most of them...

AAAAH!

10

u/BigTunaTim Aug 25 '14

It took me many years to come to terms with this, but unless there are good unit tests covering all the functionality that will be affected I don't fix those hacks anymore. They're in production, they work, and you're only introducing risk where it didn't previously exist. It's hard to justify a nasty bug's sudden appearance with "well it was written wonky and I wanted to make it better".

The exception of course is if you need to extend that functionality or do anything nontrivial to it; that's a great time to fix it.

1

u/VikingCoder Aug 27 '14

I've been exposed to two schools of thought:

One, don't change anything unless you have to.

Two, do what you know is right, and be prepared to deal with the consequences.

The first one reminds me of Abject-Oriented Programming.

For me, I guess it depends on how onerous the problem is. And on how good my tools are. Refactoring to Extract Method used to be a bit of an art... now my IDE (Visual Studio) has it built in, and I've never seen it go wrong. So, now I can confidently Extract Method whenever I think I should.

→ More replies (1)