Iris Classon
Iris Classon - In Love with Code

Ask Iris: How do you find and debug errors/bugs? (Q 225-226)

[To celebrate my first year of programming I will ask a ‘stupid’ questions daily on my blog for a year, to make sure I learn at least 365 new things during my second year as a developer]

iris classon - how should I debub?

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

V
8/7/2013 11:55:32 AM
Hey,

I think this is a great approach to find bug/errors. In my job as a developer i have several situations where the "Discuss with colleagues, forums ,social media" is often the breakthrough in finding the cause of the bug/error.

/A 
Ben
2/24/2016 5:57:02 AM
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

comments powered by Disqus