Debugging technique: Set up a fast-repro
Sometimes you’re working on a large codebase, and there is a bug you need to fix.
It takes a while to reproduce - you have to wait for it to build, deploy, launch, then actually get to the spot where the bug is.
If all of that takes long enough, and you haven’t solved it within half an hour or so: consider reducing the “time to repro”.
You have a few techniques to do this:
- Isolate that part of the code into a brand-new project. Yes this will take time to set up, but it could save you hours of accumulated delays testing in the full project.
- Short-circuit the project logic so you start immediately where the bug is. The best version of this is pretty much a test - you start the project and it performs the repro case immediately. Comment out code, disable components, be aggressive.
- Build debug tools to achieve #2 with the added benefit of others being able to use them, including future you. This will take the longest but has the largest payoff.
Be careful that you don’t change enough to where the bug doesn’t occur because of your changes.
Let me know which one works for you!