Previous Section Table of Contents Next Section

Appendix A. Classification of Bugs

This appendix details the bug classifications used in this book. Appendix B, "Index of Bugs by Type," allows you to quickly find all the bugs of a particular type. (Ideally, you should only consult Appendix B after the problems are solved because knowing the type of bug in a particular example makes it easier to find.) Because of the imprecise nature of the bug classification, there is some overlap. In many situations, a particular bug can be classified in several different ways.

When talking about bugs, there are really three types-failures, faults, and errors:

  • A failure is visible to the end user of a program. For example, the program is supposed to print a one and instead prints a zero.

  • A fault is the underlying state of the program at runtime that leads to a failure. For example, the program might display the incorrect output because the wrong value is stored in a variable.

  • An error is the actual incorrect fragment of code that the programmer wrote; this is what must be changed to fix the problem.

(This distinction between failures, faults, and errors is provided by a paper written by Andrew J. Ko and Brad A. Myers of Carnegie Mellon University.)

A failure implies at least one fault, and a fault implies at least one error, but the reverse is not true. As programmers know, errors can lurk in code that appears to run perfectly, and an inconsistent runtime state might not lead to an actual user-visible failure.

When this book (and the classification of bugs that follows) talks about "bugs," it really talks about errors. All the errors in the programs are of a type that leads to faults and failures-at least for certain inputs.

Many of the errors discussed in this appendix are demonstrated with short examples written in C, Java, or Python. With the exception of a few cases where an explanation is given, the language should not interfere with understanding the code.

    Previous Section Table of Contents Next Section