RE: [PEAR-DEV] Re: DB Exceptions - Sample Code
| From: | Hundiak, Arthur | Date: | Fri, 09 Jul 2004 14:46:25 +0000 |
| Subject: | RE: [PEAR-DEV] Re: DB Exceptions - Sample Code | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-31797@lists.php.net to get a copy of this message | ||
I added a sample DB_Exception class tree to the code.
http://www.cerad.org/pear/index.php
-----Original Message-----
From: Lukas Smith [mailto:lsmith@php.net]
Sent: Friday, July 09, 2004 9:22 AM
To: Hans L
Cc: Sergio Carvalho; pear-dev@lists.php.net
Subject: Re: [PEAR-DEV] Re: DB Exceptions - Sample Code
Hans L wrote:
> Lukas Smith wrote:
>
>>> It's a good point that inheritance trees are a more powerful type of
>>> classifiction. You can represent generalities & relationships in a
>>> way that isn't possible with the codes. And certainly these
>>> subclasses can store specific information, which makes the argument
>>> re: empty subclasses go away.
>>
>>
>>
>> Well lets say you can define them in a more straightforward way. You
>> can define a system of how error codes are to be named that enables
>> classification in much the same way. Defining these rules is quite a
>> task however. The advantage is that once you have it, those people who
>> now this ruleset can quickly get alot of information by just looking
>> at the error code itself, whereas its alot more difficult to remember
>> full inheritance trees if you use them for classification. I dont have
>> experience defining anything like that, so I will refrain from giving
>> an example for now. However the SQL standard for example defines such
>> an error code classification IIRC.
>>
>
> You can certainly categorize / classify error codes in some sort of
> hierarchy system, but the point of using the class hierarchies is not
> for readability (we have messages for that) but so that you can
> selectively catch() these errors in your scripts, or catch() groups of
> errors, etc. I can't think of a more natural way of representing
> hierarchy in OO languages. So, if hierarchy is important to error
> codes, exception subclasses seem the way to go. If the error codes are
> flat then I'd probably use error codes -- if anything. Depends on the
> package, I feel.
You forget that we dont only execute but also read code. So if you
categorize by hirarchy you end up with insanely long names. Anyways the
point i was trying to make is that you can categorize using error codes
and that error codes are a very concise string which people in the know
can levarage to get alot of information from a tiny string. Of course
for the unwashed it must be easy to look them up in a mapping table.
Note what I am talking about here has nothing to do with code that is
being executed, since a machines are not affected by this issue (in this
context the length of an error code or the depth of an inheritance tree
are not relevant issues).
regards,
Lukas
--
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php