Scientific method of debugging

The scientific method of debugging can be broken down into the following steps
  1. Identify the bug you want to fix.
  2. Form a hypothesis.
  3. Create a test for your hypothesis.
  4. Prove your hypothesis correct or incorrect.
1. Identify the bug you want to fix.
Enumerate the evidence you’ve seen regarding the issue.

2. Form a hypothesis.
Before changing any code, take a guess at what might be happening. It doesn’t have to be a good guess—it just has to be something you can test. This is called your hypothesis.

3. Create a test for your hypothesis.
Come up with a way to test your hypothesis. You want something that can give you a “yes” or “no”.

 4. Prove your hypothesis correct or incorrect.
If your hypothesis is correct, you’ve found the issue. Fix it and move on. If your hypothesis is incorrect, log this fact as the next piece of evidence and then come up with a new hypothesis based on all of the evidence, including this.