Michael Philip Favila
Published Dec 8, 2018
When working on a new software application or maintaining an existing application, there will be a time that you need to debug and figure out the root cause of an error. Debugging can be frustrating, time-consuming, and a total blocker. From my experiences, here is the list of things that I did and learned that I find highly effective and useful. They help eliminate my doubts and assumptions and improve my problem-solving skills.
- Start with a proper mindset and attitude. Anything can go wrong so have patience, focus, determination.
- Analyze and replicate the problem. It's difficult to fix an issue that you can't simulate.
- Check the error logs for direction. Analyze properly as sometimes the message is misleading.
- Follow the trail, go through the code line by line. If necessary, log each step.
- Comparing with something that works and comparing to last working state. What actually changed, what's different now or in that environment.
- Avoid spoon feeding. Try first before asking your peers or asking your best friend (google). Do the initial investigation on your own. The solution might be easier than you thought.
- Tooling. I highly recommend using a debugger and a logger. A proper tool can make a lot of difference in efficiency.
- Now, if you get stuck, don't be shy, it's OK to ask for help. Explain the problem, share what you've done, and state your thoughts. Don't be annoying, do not ask the same question over and over.
- Do a cross-peer debugging or a mob debugging. More eyes are better than 2. It is easy to see other's fault than to see yours.
- It's alright to have a break if you feel exhausted and overwhelmed. Take a power nap, get a cup of coffee, go for a quick walk, look afar, etc.
- Timebox, give your self a time frame. If you did not manage to figure it out within that certain period of time, switch to a different task and continue later.
- Write a unit test, fail early and learn early. As much as possible, try to have a 100% code coverage.
- An assumption is the mother of all fuck-ups. Test your thoughts.
- Avoid having a different environment setup: your development, staging, sandbox, integration, and production must be identical.
- Make no excuses. If you are not familiar with the codebase, familiarize it! You really won't figure out the problem if you don't dive in. Get your hands dirty. Just do it.
- Retrospective, look back, go through all the steps you've done, and identify the mistakes you made to make sure it won't happen again. Ask yourself, What approach will you do next? List all the takeaways. It doesn't matter whether it's negative or positive, the important thing is you learned from them.
- If all else fail, try turning it off and on again :)
Hope this article helps you with your next debugging journey. I would like to hear your strategy as well.
Have fun coding and debugging!