Global Moderator
Internet Junkie
Gender:
Posts: 1523
6847 credits Members referred : 8
Gimme all your cookies!!!
« on: Dec 12, 2005, 05:37:54 PM »
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.
Global Moderator
Internet Junkie
Gender:
Posts: 1523
6847 credits Members referred : 8
Gimme all your cookies!!!
« Reply #2 on: Dec 12, 2005, 06:00:17 PM »
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.
Global Moderator
Internet Junkie
Gender:
Posts: 1523
6847 credits Members referred : 8
Gimme all your cookies!!!
« Reply #4 on: Dec 12, 2005, 06:17:56 PM »
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.