Bugs Versus Exceptions

This chapter shows what tools will help you avoid bugs, find them early, and squish them when they are found. There are some conditions, however, that appear to the user as an error but are not bugs—exceptional and unavoidable circumstances that you can not eliminate. Circumstances such as running out of memory, running out of disk space, or dropping a network connection. Not your fault, but they'll bring your program to its knees just as quickly as dividing by zero. You have to handle these problems.

The traditional approach to managing these problems is to crash, but that is frowned upon these days. Better yet, allow the user to fix the problem and continue. Better still is to fix the problem yourself (assuming you will do no harm) and not make the user aware of the problem.

In any case, these situations are not bugs, but exceptions. Before looking at how to find and eliminate the bugs in your program, let's look at exceptions.

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.