Tuesday, February 8, 2011 at 5:59AM
These are the top 4 general debugging tips that I have used in my development across multiple languages, and are not specific to any one language but instead just general ideas.
- Track your changes - keep a log of all of the things you have changed and tried while debugging this problem. This way when you finally swallow your ego and decide to ask for help, you can give that person this full list of everything that has already been tried and shorten their debugging cycle. If your going to be posting your question to a site like StackOverflow this gives valuable information to the people trying to answer your question and gives your post a much higher quality, which should translate into higher quality answers. Creating this list will also allow you to avoid repeating the same steps over and over again while debugging.
- Don't Trust Comments - Read your code. Comments should be a guide/reminder as to what the code should be doing, but comments are not code, they cant actually do the work. You need to read and walk through your code to actually debug a problem. This is especially true when reading other people's code.
- Get Help - Talk to someone. Post a question to StackOverflow or dont. The act of explaining your code forces you to reevaluate your logic.
- Walk Away - Get away from the code, take a walk, get something to eat and then come back to the problem with a clear head. Pounding away at a problem can force you to be very narrow in your analysis but stepping away from the computer and just thinking about something else can help you reevaluate the problem as the bigger picture.
Post inspired by the teachings of John Guttag.