I'm writing class files, and often use the same typical format for each class (think standard database/web form classes). As I'm constantly trying to refine the way I do things, I'm wondering if this would be good practice.
Basically, I'm thinking of using custom error reporting in my class files. Have a simple constant at the top of the class file, and then within the class at critical places, have some custom errors.
Here's a silly example of some Person class:
define("DEBUG_MODE", "on");
class Person {
...
function SetName($name) {
if (strlen($name) > 0) {
$this->name = $name;
return true;
} else {
if (DEBUG_MODE == "on") {
echo("<strong>Custom Error:</strong> ".$name." is not a valid name.");
}
return false;
}
Ok, it's a trivial example (sorry for any errors in the above; I just made it up). My point is, would something like this be worthwhile, or would it needlessly bloat my class files? I don't usually find debugging to be a problem, and realistically most of the stuff I write isn't super complex... what do you think?