Error checking - When is too much.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

Error checking - When is too much.

Post by EricS »

This is more a question about theory than an actual coding problem. I've been taking error checking very serious of late and am getting better and better at. But it seems that you could error check just anything you do and my code is starting to look more like one big error check than an application. I don't mind writing the code, it's strain that all this overhead is adding the server that I'm worried about.

For instance. I'm writing a template class that receives a filename, checks that there is in fact a filename passed, checks that the file exists, reads the file, checks that it has in fact read something in and is not just empty, implodes it to string and sets the string to a class property. Then when you want to modify the template, it checks that you have a template already set, checks to see if you've actually given any changes, and then makes the changes. Then when you want to display, it checks to see if you have a template set, then displays the template, and tells the calling script that it's succeeded or failed.

Is this going overboard. Should we be striving to have PHP applications that never show those nasty default PHP errors, and instead show nicely formatted error that were prewritten by guess who....ME.

What do you think? Smart Programmer or Eagerly Over Zealous.
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

I think it depends on what type of site you're coding for. For example I just finished an ecommerce site that passes data to an AS400 for processing. I had to do error checking out the ass to make sure good data was getting passed.

If I was doing a little personal homepage I dont think it would matter nearly as much. It can't hurt to be too careful.
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post by fractalvibes »

I think you are on the right track with the error checking. To some extent I have to interface Web stuff with an OS/390 behomoth and ancient systems, and whole-heartly agree with Jim. I think you will always find yourself writing a bulk of code to handle the odd situation, the exceptions.
A pain, no doubt, but in the long run will save you much grief.

Phil J.
Post Reply