Uncertainty in Debugging

This situation has happened to me several times recently: I was testing my program using some testing data. Part of my program output was not compatible with the correct testing result. So I began inspecting my code and reasoning the potential problems in my design. Then I did find several vital flaws in my code. However after correcting those errors, the output still seem wrong. The previous flaws in the source code made me lose confidence about my code and become fearful about other bugs I may overlook. Then I began to test the code piece by piece. The process may take a very long time, and even worse after tested every single part of the program, it turned out every single piece seem to work correctly. Nevertheless the output of the whole program still differed from the correct ones. Many times the differences were rather weird. Finally when I almost gave up, it turned out somehow the testing data is not correct at all. After altering the testing data, the output of my program turned to be perfect. What about those vital errors found with the wrong testing data? Would my code also work without modifying those errors? I did not know. I just simply did not want to go back and test again so long as my code agreed with the "correct" testing data.

Lessons learned:

- Written on Sat Apr 18 20:15:34 2009.