Liz Lam always learning     About     Archive     Feed

Don't Assume While Debugging

One of the most frustrating and rewarding parts of software development is figuring out a problem. We’ve all been through it. A user reports a bug and you meticulously comb through every line of the corresponding code base and nothing. How many times have you walked through the same piece of code over and over again with a debugger trying to figure out exactly where the culprit is? Sometimes it feels like a treasure hunt, where the treasure map is missing some important directions.

The software application I currently work on deals with aligning spatial data with blueprints/models in order to detect discrepancies. One way to align the spatial data with the model is to enter a transform (x,y,z,rotation). This transform gets applied via matrix multiplication. The feature was not working for all datasets and I had to hunt down the reason why. I performed some trial & error and utilized the console to dump the variables to see what was going on. I hand-calculated the matrix multiplication several times and discovered the error was in the assumed correctness of the math formula.

It was an interesting exercise to go through and even forced me to dig out my old Linear Algebra textbook. It was a reminder to not make any assumptions about the correctness of any part of the code during the troubleshooting process.