fix the bug test the fix reproducing the bug is sometimes easy--it always occurs on every runand sometimes hard--it occurs intermittently in either case we should try to reduce the bug' dependenciesthat isfind the smallest input and the least amount of processing that can still produce the bug once we are able to reproduce the bugwe have the data--the input data and optionsand the incorrect results--that are needed so that we can apply the scientific method to finding and fixing it the method has three steps think up an explanation-- hypothesis--that reasonably accounts for the bug create an experiment to test the hypothesis run the experiment running the experiment should help to locate the bugand should also give us insight into its solution (we will return to how to create and run an experiment shortly once we have decided how to kill the bug--and have checked our code into our version control system so that we can revert the fix if necessary--we can write the fix once the fix is in place we must test it naturallywe must test to see if the bug it is intended to fix has gone away but this is not sufficientafter allour fix may have solved the bug we were concerned aboutbut the fix might also have introduced another bugone that affects some other aspect of the program so in addition to testing the bugfixwe must also run all of the program' tests to increase our confidence that the bugfix did not have any unwanted side effects some bugs have particular structureso whenever we fix bug it is always worth asking ourselves if there are other places in the program or its modules that might have similar bugs if there arewe can check to see if we already have tests that would reveal the bugs if they were presentand if notwe should add such testsand if that reveals bugsthen we must tackle them as described earlier now that we have good overview of the debugging processwe will focus in on just how we create and run experiments to test our hypotheses we begin with trying to isolate the bug depending on the nature of the program and of the bugwe might be able to write tests that exercise the programfor examplefeeding it data that is known to be processed correctly and gradually changing the data so that we can find exactly where processing fails once we have an idea of where the problem lies--either due to testing or based on reasoning--we can test our hypotheses