Sublime directory Surf the web anonymous Pagerank Monitor


Coding Tip

wineo
Mon 12 December 2005, 04:37 pm GMT +0100
I just thought that should share a coding tip. I use it when coding in PHP, but it would apply to any coding language.

When coding, always test to break the code first and ee that you have caught all the errors first.

For example (a simple example), if you are checking for a certain value in an array, first check that the error reporting works when the value is not in the array. You could even (and I do this quite often) ask someone else to try and break you code.

HTH!  8)

Nikolas
Mon 12 December 2005, 04:45 pm GMT +0100
I am not sure what you are talking about.

Can you explain a little bit more?

wineo
Mon 12 December 2005, 05:00 pm GMT +0100
Well, when I code, I always check that the errors are caught and that they are handled correctly. I always do this first, because if you leave them to the end, they never get done.

Nikolas
Mon 12 December 2005, 05:05 pm GMT +0100
Oh I see.

Something like this would propably help : http://www.webdigity.com/index.php/topic,92.0.Custom+error+reporting+script.html

But you can allways see the php_err log files on the server (if you have access of course)

wineo
Mon 12 December 2005, 05:17 pm GMT +0100
I was talking about a coding practise or even a habit that I have developed where I check the code/page while I am developing it on the development server.

Another simple example - take querying a database for example. When the query to the database errors or fails to connect, an error message or flag should be set. Now when you coding, you should try and break it to check that you error catching and warning systems are in place and working. If they are, move onto developing the next section of code.

You don't always catch all the errors when developing and the code that I posted in that thread that you pointed to will catch any unforseen errors.

Nikolas
Mon 12 December 2005, 05:24 pm GMT +0100
Now I almost got you :) (I know I am a really stupid person)

It is allways good to have some debug tools of your own and use whatever possible that will help you examine all the possible actions in a program.

An error catching script will also help a lot, as you can't make a perfect application without testing in a real environment.

wineo
Mon 12 December 2005, 05:38 pm GMT +0100
Yeah, something like that!

BTW you are not stupid, you know a lot of stuff that many others know nothing about! We know some stuff that Einstein never know!!! 8)

Nikolas
Mon 12 December 2005, 05:40 pm GMT +0100
Hehehe.right :)

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional