« Collective code apathy | Main | How Wrong I Was! »

February 11, 2005

Always check your blind spot!

As I left work last night, I'd just caught wind of a bug in the piece of code I was working on. From the gist of the bug, and my familiarity with the code, I quickly came to a pretty good diagnosis of the problem. In short, a piece of code which filtered records based on date were excluding records added on the current day. The code used a predicate in the form:

lowDate <= recordTimestamp <= highDate

My hunch is that these new records all contain timestamps along the lines of dd/mm/yy hh:mm:ss, whereas the highDate contained dd/mm/yy 00:00:00, so any record created on the day will be excluded based on the fact that almost any value of hh:mm:ss is not less than or equal to 00:00:00 (except for those lucky enough to have been created exactly at midnight).

After a bit of thought, it occurred to me that I'd introduced this problem before...

On my previous project...

Further consideration brought forth memories of other projects gone past where I'd also written this bug into the code.

In fact, I'm fairly sure I've seeded this nasty into the codebases of almost every project I've contributed on in the last 8 years or so!

A definite blind spot in my developer mind. Either that or the symptom of some Manchurian Candidate-style brainwashing... to what end, I'm not entirely sure?

Perhaps I should just insert the failing test case into the test suite of every new project I work start on, to head off the seeming inevitability of this bug reappearing.

Posted by Andy Marks at February 11, 2005 07:30 PM

Comments

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?