Debugging Skills 5 lessons
  1. 1 Debugging is a method, not a talent
  2. 2 Reading what the program tells you sign in to open
  3. 3 The difficult bugs sign in to open
  4. 4 Fixing it properly sign in to open
  5. 5 Debugging in production sign in to open
Course overview
Data: video · change

This lesson: 122KB

Debugging Skills · Lesson 1 of 5

Debugging is a method, not a talent

Replace guessing with a process.

Most people debug by changing things until it works. That occasionally succeeds, teaches nothing, and frequently leaves a second bug behind.

The method is the same every time.

Reproduce it reliably. A bug you cannot reproduce is a bug you cannot verify you fixed. Find the exact conditions: which input, which user, which sequence. This step is frequently most of the work and it is the step people skip.

Read the error properly. The whole message, the whole stack trace, from the top. Beginners read the first line and start guessing, and the information they needed was four lines down.

Form a hypothesis, stated explicitly. "The list is empty because the filter runs before the data loads." A specific claim can be tested; a vague sense that something is wrong with the loading cannot.

Test the hypothesis with one change. If it was wrong, undo it. Leaving failed attempts in place is how a codebase accumulates code nobody can explain.

Narrow it down. Cut the problem in half. Does it happen with simpler input? At an earlier point? With one component removed? Bisecting finds a bug in a few steps that random inspection does not find at all.

Then fix the cause, not the symptom. A null check added where the crash appeared leaves the real problem, which is whatever produced the null, and it will resurface somewhere less convenient.

Lab — try it yourself

On your next bug, write your hypothesis down before changing anything. Then test only that. Notice how often the first one is wrong.

Check what you learned

Create your free BvLogic ID to take the quiz and record your score.

Create your BvLogic ID
Continue to lesson 2 Up next 2. Reading what the program tells you