As developers we’ve all been there, banging our head on the table thinking, “Why is this not working?”, staring deeply into our code asking why. Knowing that we’ve gone through the right process to make this work, and for whatever reason, it’s not. Occasionally, there may be something strange going on to cause this, however, more often than not it is just a simple solution that we somehow missed.
The simple solution is usually the proper solution. This idea is known as Occam’s Razor. It’s more commonly associated with the medical field, however, it’s a very useful philosophy to use for debugging. Point being, don’t overlook the basic things when debugging a program. Now, let’s go over some of the questions to make sure to ask before spending too much time pulling your hair.
Am I in the right file/server?
This one seems like a no-brainer, but it can be sometimes overlooked. Especially when you deal with quite a bit of sites on quite a bit of servers. A good way of checking this is just printing out something, anything, to show that you are changing the right file.
Is this the right version?
There’s quite a bit of libraries out there to be used, and they are constantly being updated. Make sure that you’re trying to do something that works in the version that you have.
Are permissions set correctly?
File permissions can be a tricky thing sometimes. Make sure that your program has permission to use your files.
Did I spell it right?
This one happens a lot. Just check your spelling.
Is the casing right?
Letter-casing is important. Make sure you got it right.
Does my data look right?
When in doubt, print it out. Check your data!
Am I using the right function?
If it’s a custom function, check the source. If it’s a built in function, check the docs.
Are these parameters right?
Check what you’re passing into the function, make sure it’s the right type of data, and in the right place.
What’s the error message say?
This one is most important. If you have an error message, read it, and read it carefully. It usually will tell you exactly what is wrong.
Point is: Do sweat the small stuff. When it comes to solving a problem. The solution is usually right in front of you.
Like this post? Have a question on development or design? Contact Us, and we just might answer it for you!