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.
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