Standard Operating Procedures: Debugging

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Standard Operating Procedures: Debugging

Post 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?
Last edited by harrisonad on Wed Aug 17, 2005 11:37 pm, edited 1 time in total.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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 ;) )
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

programming

Post 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.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post 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.
Post Reply