Chapter 21. Exceptions and Debugging

In 1992, Jesse Liberty worked for Pat Johnson, who used to say "Save time—don't put the bugs into your code in the first place." Good advice.

It turns out, however, that bugs do creep into your code. But here is what we know: the earlier you find a bug, the cheaper it is to fix. Bugs found just as you are entering the code are the cheapest: just hit delete and fix the code. Bugs found during compilation are next cheapest: compiler bugs fail every time, and if you are careful you can squish them all before you show your code to anyone else.

Bugs that make it to Quality Assurance (QA) are more expensive than bugs you find when you compile the code, but they are a heck of a lot cheaper to fix than bugs that make it all the way to your customer—the most expensive bugs of all. The bugs you want to avoid are the embarrassing ones that show up when you demo your new product to your prospective customer, or that show up months (or years) after you've sold the product. Fixing those bugs require you to do something that every programmer hates: go back to code you're done with to reopen it and see all the dopey things you did when you were young and stupid.

Get Programming .NET Windows Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.