News for hackers. Stuff that matters.
Re:My 8 hour journey to a single character by chipsy on Monday November 23, 2009 @12:55PM (#957767)
I just fixed a "should be || was &&" logic error that manifested itself fairly mysteriously in a one-dimensional partitioning data structure I had made(meant for indexing things like collision rectangles that have a "canonical value" and a "represented value" which need to be synchronized).

When it removed elements, it was matching both the represented value(an integer) and the node(an object reference). Using && meant that it removed too greedily. Because updates always went "remove then add," this error went undetected until I hit the case where two or more objects shared an identical reprval. Then it removed all of the shared objects, leaving only one behind when I went to query the partition. After going through "Does my query function work right, does my list implementation work right, " I finally narrowed it down to the add/delete functions.

Re:My 8 hour journey to a single character by mleonhard on Monday November 23, 2009 @03:16PM (#958047)
That sounds like an error that would have been detected by a unit test.
Re:My 8 hour journey to a single character by holygoat on Tuesday November 24, 2009 @02:28AM (#958869)
Being a little snide... that sounds like a unit test that occurs to you after encountering that bug.
Re:My 8 hour journey to a single character by chipsy on Tuesday November 24, 2009 @09:00AM (#959183)
It's a conceptual error with the problem, which means that it indeed WAS missed by unit tests. I wrote some of those and checked the "overlapping numbers" case; the difference was that I did so in a naive situation where the values were inserted once and never updated.

Now, it would have gone from a "mysterious" error to an obvious one had I done an academic-style step-by-step visualization applet of the entire structure's processes before integration, but I had confidence when the code was first written that because this structure was being used with extremely high frequency, the only thing I had to write an explicit test for off the bat was off-by-one ranges causing edge-case "near misses"; anything else would make itself known at runtime after integration.

Time it would have taken for a visualization applet: ~3-6 hours? Time it took to solve the bug: ~3 hours

It's placing a bet - and the bet is that the bugs are limited to a specific segment of code that can be narrowed down easily; if the problem were architectural in nature I'd be in far deeper shit because that would make the same class of bug appear all over, with any number of different symptoms.