Friday, January 11, 2008

There are no bugs in software

A 'bug' is a wingless or four winged insect with mouth parts adapted for piercing and sucking of the order Hemitera.

Code does not have bugs, it has defects!

When you make an error in your thinking (or your typing) you introduce a defect in your code, if you do not catch it before it goes to testing (or worse, it ships) it will show up as a fault when the code is running. Faults are caused by defects. Defects are caused by errors. Bugs hatch from eggs.

Defects are cancer in code; the earlier there are detected the easier they are to remove.

  • If it is detected before it is checked in, it is as if it never happened.
  • If it is detected by the testing team, it can be eliminated before the customer sees it.
  • If the beta testers detect it, it will not ship to the main customer base.
  • If it ships, you will need to deal with it for as long as the defective release is being supported!
For this reason it is best to catch defects ASAP! It is best if the compiler can catch them. Next best is if they can be caught by the automated unit tests run automatically by the version control system. Either way they will not be checked in.

We are convinced that code is defect free when either:

  1. It is so simple there is obviously nothing wrong with it
  2. or
  3. It is so complex there is nothing obviously wrong with it.
The first is fine, the second is not. Never give code the benefit of the doubt, if you are not sure it is defect free, assume it is defective. You should only assume code is defect free after you have:
  1. Mathematically proven it to be defect free (and proven that your proof is correct),
  2. and
  3. Run it through a full coverage test suite that deals with restricted resources, device failures, all possible timing issues, and all other possible condition under which the code could fail (such a test suit is probably not even theoretically possible).
Since it is very rare (if not imposable) to do either of these, let alone both, it is very rare that you can assume code to be defect free.

But always remember, bugs do not sneak into code, programmers put defects there!

Labels: