Welcome to the OzoneAsylum FaqWiki
Tutorials
Server Side Scripting Tutorials

How to properly debug a server side program Pages that link to <a href="https://ozoneasylum.com/backlink?for=4966" title="Pages that link to How to properly debug a server side program" rel="nofollow" >How to properly debug a server side program\

Programming takes logical thinking.
Straight, logical thinking.
With this in mind, our mood, emotions, feelings, beliefs can influence
our tendencie to make mistakes while programming.

I'm talking about those times when you think "dare I do that, won't it crash my machine?
Will I reduce my hard drive to a toast by pressing this little button?"
Well, understand that if you can press the little button, it is
probably that it won't destroy anything in an irreversible manner.

Otherwise, the creators of the machine would have kept the "fatal trigger" hidden.

Anyway, the point here is a quick list of what you can do to properly
debug your own code:

- know the language error messages

No matter the language you use, it has it's own warnings and error mesages.
Learn what they mean, either from the manual, either by experience.
Tipically, in php or asp or javascript, these warnings report the line
where the error occured, it helps spotting the problem and often, the solution.

- track and display your variables and their values

There always is a simple way to display the value of one, or several variables.
It is probable that you know which values you can expect from which variable,
what it should contain, or at least the type of the variable.
Being able to inspect those variables and how they evolve during execution,
you'll spare yourself some headaches.
Especially when it comes to errors... That don't throw a warning.

- test your configuration

Moving from one server to another, one environment to another, things
could change and cause a correct code to react oddly.
Get to know your working environment, tipically, moving from a windows Apache
to a Linux Apache, or a PWS to an IIS.

- test functions separately

Something in your code is wrong and you suspect it is in "that" function?
Isolate the function, make it a stand-alone thing, and things will get a lot clearer.

- ALWAYS backup your working files

You just achieved something *great*, well, take that good habit to backup
you file(s). If possible, make a bakcup of the whole program each and every time
it is needed.


If you leap some of these steps, you could find yourself strongly fixed to a false idea
of what the error could be.
Because your (and my) human mind will tend to discard what seems unprobable.
Do like Sherlock Holmes used to do: programming is about logics, logics is about
straight facts, discard all the possibilites, one by one, and what remains,
even if unprobable, will be the truth.

(Added by: InI on Tue 21-May-2002)

« BackwardsOnwards »

Show Forum Drop Down Menu