25 Debugging Techniques Every Software Developer Should Master
Principles
- Observability. Program should output its progress so you can see which codepaths are being taken
- Logging: delinate between log levels: TRACE/INFO/DEBUG/WARN/ERROR/FATAL
- Tight REPL
- Root-cause. Always find the root cause of why the bug happened. You shouldn’t be satisfied with a surface-level reason
- Verification. Code should be verified
Techniques
- Systematic Reduction. This is done both in time-axis and space-axis:
- Time: which version (commit) introduced the bug?
- Space: which line of code introduced the bug?
- Static program analysis. Ranges from simple to proper:
- Linters
- Using typed languages (Algebraic Type System)
- Functional Programming languages
- Formal Methods
- Testing. With tests, you can make changes without fear that it’ll break something without you knowing
- Tight REPL. Your debugging harness should be setup for a very tight REPL loop. The longer it takes to get the feedback, the less efficient, and more frustrating.