Problem Solving – Original script – November 2013

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.

Cast

  • 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.

General process

  • 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:

  1. Has it ever worked?
  2. Did it actually work last time?
  3. What have you done?
  4. Did you actually change the program?
  5. Are you running the program you thought you’d changed?
  6. Are you looking at the right output?
  7. Have you changed the inputs?
  8. Does the code match the comments; if not, which is wrong?
  9. Is it repeatable;  if not, give up until it is?
  10. 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

  1. Do the Google search that the asker should have done. Is this the modern day equivalent of RTFM?
  2. Ask the asker if they have reduced the problem to the simplest version that exhibits the bad behaviour.
  3. Ask the asker if they have compared the results with the most recent regression test.
  4. Ask them to repeat the problem on another machine.

If you’re the stupid question asker

Ask the asker

  1. Can you explain it to me again?
  2. Does it make any difference what day of the week you run it?
  3. Did you reload the data from yesterday’s dump?
  4. Does it work on Windows?
  5. Would you expect it to work when ‘whatever’ is not available?
  6. 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.

Further reading

References

Originally published as a blog post containing additional notes for PHPHants November 2013. Top 10 questions to ask when something doesn’t work.

About herb

Herb Miller, the owner of Bobbing Wide, develops WordPress websites, plugins and themes. He is the creator of oik-plugins, WP-a2z and Seriously Bonkers.