Debugging sucks. It’s a painful process that every programmer has to face at some point. Unless your are using an application that lets you walk through your script line by line, then it can be a pain in the pocket protector to find your error. Here are 6 tips that can save your sanity while debugging.
If your script isn’t working, make sure to look out for the basics before you have a heart attack:
- Declare your variables with descriptive names. This way at least you’ll know what your using and where/why it’s being used.
- Check your opening and closing tags. Every script has their own. Make sure that they open and close when they need to. This can be especially tricky when it comes to loops, so keep your eyes sharp.
- Make sure your passing the right arguments. Check out what’s being passed by printing the value on the screen. This way you are working with what you really think is really there.
- Check your syntax for basic misspellings. This means double checking the name of your functions, all it takes is 1 character to mess up a script. Make sure your calling calculateData(), not calculteData().
- Relax. If you can’t find your error, take a break and come back to it. There is no reason to get your panties in a bunch if you can’t find your bug. Unless of course your on a deadline, then you better get your ass to work and find your error.
If you still have script errors, search the net to see if anyone wrote code similar to yours. Better yet, check out Krugle.com. It’s code you can search. Check out their demo first so you can get started fast. Hopefully then your script will run nicely.