Tuesday, June 19, 2007

Byte: The coding equivalent of two bald men fighting over a comb

We're in the middle of Factory Acceptance Testing at the moment, and I've just spent the morning nailing down the cause of an error that is preventing our build being signed off to go up to Scotland in a fortnight for Site Acceptance Testing.

It was a VB13 Subscript Out of Range error that was happening when the code was validating that the callsign of a Search and Rescue asset being returned in an SQL cursor is not null. Because of the way that VB "Is Not" statements work, this code was falling over when the variable it was doing the "Is Not" on was alphanumeric, rather than a number. This was curious enough, but when I actually analysed what the code was doing, I found out that the check itself is utterly, *utterly* redundant. This is because the structure of the code around it bypasses the check is the cursor doesn't return a callsign and furthermore, the callsign being returned by the cursor comes from a column that's the primary key on the table it belongs in - in other words, it has to be unique and can NEVER be null. So why check if a value that can never be null is null? If that's not the very definition of futile, I don't know what is... ah, I love my job.
Post a Comment