Bugs are a fact of life. It doesn't matter how good a programmer you are, there will always be bugs in your code.
Here's Jill:
It won't work. There will be bugs. Death, taxes, the Chicago Cubs never winning the World Series, and bugs. They are the only things you can count on in life.
Having bugs in your code is not a sign of failure. It's just part of the writing software. If your code never has any bugs, that's a sign that (1) you don't write code, or (2) you're lying.
Bugs are frustrating. But they're not scary, once you learn how to kill them. You can kill the critters crawling around your screen. (Can you figure out how?) You can kill software bugs, too.
Debugging is like a detective story. There's a crime (e.g., wrong output). You question witnesses (e.g., look at the values of variables), and check their alibis (why do they have those values?). You eliminate suspects (e.g., variable total
isn't causing the bug). You find the culprit (e.g., Aha! interestRate
is an Integer
, and it should be a Single
). In debugging, there's only one penalty: death!
Chant: Death to bugs! Death to bugs! DEATH TO BUGS!
Just like a detective story, each case is different. Different clues and different witnesses. You need to think about it. To be fair, debugging is easier than figuring out a Sherlock Holmes case. Debugging is something's-wrong, what-causes-this, there-you-are, die!
Let's start our entomological excursion by identifying types of bugs.