Ask Iris: How do you find and debug errors/bugs? (Q 225-226)
Debugging is a skill, and a skill I get to work a lot on. A few times I’ve been asked how I debug and locate errors, and I’ve had many interesting discussions about that. I’ve learned how to debug through experience, books such as Code Complete 2ed (has a great approach to debugging and I’ve adopted some of it, although I have to admit my flow is a little bit different), colleagues and courses.
Here is my approach (more or less) and I like to divide into question, action and how
Question:
What is the error?
Action:
Reproduce
How:
Messages:
Error messages
Log messages
Test messages
Next question:
Where is it?
Action:
Pinpoint
How:
Recent changes (commits etc)
Top down tracing
Try to isolate the area
Questions:
Why the error?
Action:
Create theories, get help with theories
How:
Make up some ideas/theories
Discuss with colleagues, forums, social media
Keep in mind recent commits/changes
Then decide the best solution after making sure I
Really know the error
Where it is
And why it exists
Comments
Leave a comment below, or by email.
V
Ben
Knowing ALL of this after only one year of learning? I feel so inadequate. the way i debug: (1) avoidance: plan well. AND (2) write code one line at a time and constantly check. (3) write tests to constantly check. (4) view the stack trace to see where the error was - why it happened. that's how i do it.
Last modified on 2013-08-03