There was a bug in our software where a crash occurred when an address with over 50 characters was specified. For the fix, the developer changed the code to truncate the text down to 49 characters.
“why are you using 49 and not 50?”
Me
He thought the “length” property was actually 1 less than there are; so 50 characters would report the Length property as 49. He was thinking of arrays where they are zero-indexed, so the first position in an array is Index 0, second position is 1 etc. Obviously he didn’t test it, and it was the wrong assumption. Length means length.
Also, there were 5 other address fields with no validation (Line 2, Town, County, Postcode, Notes). Why didn’t he add validation for them too? Just because the bug report was for the first line of the address, why wouldn’t you consider the rest of it?
After I prompted him, he added validation for all fields, truncating them to 50 except one where he truncated to 51. Why 51?
“I manually checked in the registration screen. That field holds 51 chars.”
Weird, because I manually checked it and looked at the code – it is 50. Let’s check the database column too… That’s right. It’s 50.
“Thanks, I’ve changed it to 50. Sorry, some kind of counting mistake.”
We seem to have so many developers that don’t put much thought into their work. This is one of the easiest bugs you can fix, and yet I’m basically hand-holding them through it. When there’s more complicated bugs for me to review, I end up scrutinising the code in great detail because I end up assuming they put zero thought into the solution, and didn’t test it.