Debugging is an art that needs much further study. The most effective debugging techniques seem to be those which are designed and built in to the program itself. Another good debugging practice is to keep a record of every mistake that is made. Even though this will probably be quite embarrassing, such information is invaluable to anyone doing research on the debugging problem, and it will also help you learn how to reduce the number of future errors.

From The Art of Computer Programming, volume 1.