Page 1 of 1

Standard Operating Procedures: Debugging

Posted: Wed Aug 17, 2005 11:34 pm
by harrisonad
Hi, I just want to know how do you deal with errors happening upon development of your script.

Here are mine:

Code: Select all

1. What type of error? (parsing, syntax, function, undefined, etc.)
2. Line number. If not there, maybe the lines before it.
3. a. If parsing or syntax error, let Zend Studio (or similar editor) reveal it.
    b. If undefined variables, constants or functions, 
        I. check spelling 
        II. check declarations or initializations
        III. check scope (if onlny included, check include statements
    c. etc.
4. go to devnetwork.net (please tell me where it is.).
How about yours?

Posted: Wed Aug 17, 2005 11:37 pm
by d3ad1ysp0rk
99% of my errors are stupid mistakes that I realize once I get the error output. So my error fixing involves just searching the code I just created.

Posted: Thu Aug 18, 2005 1:25 am
by McGruff
Don't waste time debugging: test. With fine-grained unit tests telling you what went wrong, the scope of the problem is narrowed down to one small area of the code making it relatively quick and easy to deal with.

Posted: Thu Aug 18, 2005 2:37 am
by n00b Saibot
I generally have defined a config.php include file for all my sites configurations. In that I set a custom error handler that provides me with error msg, file name and the code at the error location in the file, atleast one line above & one below (with color-coding too, thanks to php for this ;) )

programming

Posted: Thu Aug 18, 2005 2:58 am
by AnarKy
I find that if you write small bits of re-usable code,
then there is less chance of errors.

Also, programming in small increments helps to reduce
errors because they don’t get too compounded with a
small error leading to bigger errors.

Never, turn error reporting off while in development and testing.
The notices are especially helpful.

Correct errors as soon as possible, don’t let them slip.

Posted: Thu Aug 18, 2005 9:52 am
by nielsene
In the "old days" (last month :) ) I did:
1. Read the error message, 99% of the time its an immediate quick fix
2. If not fixed, start adding liberal applications of print_r/echo/die to isolate the error

Now I'm trying to do it the Unit Test way that McGruff and others advocate.