Debugging: How I Stop Guessing and Start Finding

Ahad Nawaz1 min read

Debugging: How I Stop Guessing and Start Finding cover image

Reproduce first, narrow the space, then fix. A simple mental model for tracking down bugs without endless printf and hope.

Debugging is a skill. Here’s the loop I use so I spend less time guessing and more time fixing.

Reproduce Reliably

If you can’t reproduce the bug, you’re not debugging yet, you’re chasing a ghost. Get steps, env, or data that trigger it every time (or with high probability). Write them down.

Narrow the Space

Binary search: does it happen before or after this line? With or without this feature? Comment out half the code path, then the other half. You’ll quickly know which side the bug is on.

Inspect State, Don’t Imagine It

Log or breakpoint the actual values: “What is user.id here? What does the API return?” Assumptions are the enemy. One minute of logging can save an hour of theory.

Fix and Confirm

Make the smallest change that fixes the bug. Then run the reproduction again. If it’s fixed, add a test or a comment so the same mistake doesn’t creep back.

Debugging is methodical: reproduce, narrow, inspect, fix. No magic, just a loop.

Comments

Sign in to leave a comment.

Keep reading

← All posts