🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Cautionary Tales in Debugging

Published July 29, 2006
Advertisement
Always name your variables well - even if you're just writing temporary hack code to try something out.


I spent several hours today (well, most of it was yesterday) tracking down a bug in some experimental vector math code of mine. It's the kind of stuff that's sensitive to real-time behavior, so you can't step through it in a debugger without ruining the numbers - scrubbing through a few MB of logs is the only way to find out what's going on.

For instance, at one point during this process, I had a couple of angle variables and was freely copying values between them. Thanks to some poor naming on my part, I was feeding radians into a segment of the calculation that expected degrees. (I later discovered that, thanks to someone else's poor namings, the part that was in degrees was wrong, and the whole darn thing should have been in radians to begin with.)

It was downhill from there.


I'll spare the long tale of woe and boredom (actually, it wasn't that bad - most of the time was spent 30 miles away at a poker game) and get to the punch line. I had two vectors, vref and vcam. They were to be adjusted via a series of rotations, producing the results av and avcam.

My final output was relying on the raw vectors, vref and vcam. The net result was bogus data getting fed down the pipeline; the visible result of that was chaotic behavior that was nearly impossible to trace to specific stimuli. In other words, the most pernicious type of bug. The type that makes a 30 minute prototyping task chew up 5 hours.



Whoops.
0 likes 3 comments

Comments

HopeDagger
Gah. I'd take the other method and just spend another 30 minutes rewriting it until it worked. :P
July 29, 2006 08:16 AM
Manaxter
I'd take the other other method where I dont touch the damn code for 30 days, and 'have a small break'!
July 29, 2006 06:20 PM
bytecoder
That's not a naming error, that's a type error, or at least it should be. Unfortunately, C++ and most other languages don't have any built-in support for units like this, although it's trivial to hack together a class per unit to avoid misinterpretation.
July 31, 2006 12:46 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement