DEV Community

Discussion on: What do you do when you encounter a hard to fix bug?

Collapse
 
eljayadobe profile image
Eljay-Adobe

If the bug can be tackled by divide-and-conquer, then I try that tact. Isolate the bad code into a small toy app. Or through a targeted integration test.

(Unit tests are typically too fine-grained to trip the bug, until you know what the bug is. Then, perhaps, you could write a unit test after-the-fact that would catch the bug... if it was a unit scope of bug rather than an integration or systems scope of a bug.)

Otherwise, I use "first grade debugging" techniques of print statements or trace points, and try to discover where the code is going awry.

If the bug appears sometime along the way as the code changes and evolves, and I have change history, I sometimes will use a binary search to see what particular check-in caused the bug. (Sometimes with the relief that it wasn't me... sometimes with dismay that it was me.)