Systematic Debugging
"Random fixes waste time. Find the root cause first."
1. Investigation Phase
- •Reproduce: Find the exact steps to trigger the bug.
- •Isolate: Remove variables until you find the minimum code that fails.
- •Trace: Use logs or debugger to follow the data flow.
2. Pattern Analysis
- •Context: When does it happen? (e.g., "Only on Android," "Only after second scan").
- •State: What is the application state (Redux/Zustand/Context) at the moment of failure?
- •Logs: Check both client and server logs for error signatures.
3. Hypothesis & Testing
- •Formulate: "I think X is happening because of Y."
- •Test: Change one thing to verify the hypothesis.
- •Verify: Did the change fix the root cause or just the symptom?
4. Fix & Prevent
- •Implement: Apply the clean, permanent fix.
- •Guard: Add validation, types, or tests to prevent regression.
- •Cleanup: Remove debug logs and temporary code.