Originally published as the Top 10 list of questions to ask when some code doesn’t work here’s a list of questions applicable to PHP developers performing problem determination aka debugging.
Note that this list was originally written in the days before Stack Overflow, WordPress answers and the like.
Well… before I was aware of them.
- The person who’s trying to solve the problem is the asker
- Any person who has been cajoled into helping is the askee
- Any person who knows nothing about the problem can be the stupid question asker
- The person who knows all about the subject is the expert
- Finally there’s the project manager
If you don’t think you fall into any of the roles above then pick one at random.
- Go through the asker’s question list.
- Next try asking the askee.
- If you still haven’t found the source of the problem find the stupid question asker and start explaining the problem to them. You’ll probably realise your mistake quite quickly.
- If you can’t find a stupid question asker then take on that role yourself.
- Still no luck, then try the expert
- Whatever you do try to avoid the project manager
If you’re the asker
Ask the following:
- Has it ever worked?
- Did it actually work last time?
- What have you done?
- Did you actually change the program?
- Are you running the program you thought you’d changed?
- Are you looking at the right output?
- Have you changed the inputs?
- Does the code match the comments; if not, which is wrong?
- Is it repeatable; if not, give up until it is?
- Are you sure it’s not working?
You can ask these questions in whatever you order you feel necessary and as many times as you like until the problem is determined.
If you’re the askee
- Do the Google search that the asker should have done. Is this the modern day equivalent of RTFM?
- Ask the asker if they have reduced the problem to the simplest version that exhibits the bad behaviour.
- Ask the asker if they have compared the results with the most recent regression test.
- Ask them to repeat the problem on another machine.
If you’re the stupid question asker
Ask the asker
- Can you explain it to me again?
- Does it make any difference what day of the week you run it?
- Did you reload the data from yesterday’s dump?
- Does it work on Windows?
- Would you expect it to work when ‘whatever’ is not available?
- Were you logged in?
If you’re the expert
Have a brief look and either tell them the answer OR choose one of these
You’re doing it wrong
- It’s not possible
- I had that problem yesterday but it went away when I upgraded to version blah of thingummy
- It works fine on Windows
- You need to get trace output
If you’re the project manager
- When will you have a fix for it?
- If this went into production what severity would it be?
- Do you have a work around?
- Ask them if they have asked the expert.
This is a particularly good question if you know the asker IS the expert.
This article has now been republished as part of the Problem Solving website.