Debug [2021] 99%

| Rookie Mistake | Professional Fix | | :--- | :--- | | Changing multiple things at once | Change one variable, test, revert. Isolate. | | "I'll just rewrite the whole module" | No you won't. That introduces new bugs. Fix the bug. | | Debugging without a stack trace | First, get the stack trace. If none, catch the exception. | | Assuming the library is broken | The library has 10 million users. You are the bug. | | No version control | Use git . Commit often. Tag releases. |

Don't debug linearly. If you have a 1,000-line file, don't start at line 1. Jump to line 500. Add a return at the top. Does the bug still happen? If yes, the bug is in the first 500 lines. If no, it's in the second 500 lines. Repeat. | Rookie Mistake | Professional Fix | |

For production bugs or long-running applications, you cannot use an interactive debugger. You need structured logs. That introduces new bugs

Most comprehensive guides, including those from IBM , break the process into these essential phases: If none, catch the exception

Divide the program into sections and check outputs to isolate where the bug exists, such as testing a mid-point in a 10-step process.