exceptions
| From: | Lukas Smith | Date: | Sat, 08 May 2004 10:18:24 +0000 |
| Subject: | exceptions | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-29006@lists.php.net to get a copy of this message | ||
Hi,
well I slowly feel I have a concept of exceptions (thx george and terry for helping me along the way .. eventhough I still dont agree).
i think until we have a clear understanding of exceptions and their good uses in pear we should refrain (exceptions being done on a case by case basis) from allowing them even for php5 only packages (actually while we are messing with the concept we should allow non stable packages using exceptions).
anyways lets get a discussion going ..
btw: if anyone knows a good introduction to exceptions in php please let us know since I am sure alot of people are very unsure that exceptions really are.
Generally I see 2 decisions that need to be made:
A general definition on how to deal with exceptions that dont leak out (1) and that leak out of a package (2).
(1)
Some people think that as long as exceptions dont leak out of a certain self-contained piece of code everything goes. Including using exceptions for code flow and messaging. I dont think we should allow this. It makes the code hard to read and maintain especially if you are not the original maintainer. Furthermore there is the danger of mistakes in the code making non fatal errors fatal due to an exception leaking out by mistake. So to me exceptions for code flow is like doing surgery with a shutgun. Sure some people might be more capable with a shotgun than with a scalpel. But then again maybe we dont want these people do to surgery on PEAR :-)
(2)
Here obviously code flow messaging is out. Actually this point also covers all uses of exceptions not mentioned in (1) .. heh a general comment like this seems dangerous .. someone please reorganize my comment if possible. Here are some examples:
a) connect()
b) login()
c) find()
d) do()
for a)
one might want to throw an exception if the server trying to connect to doesnt exist, since you are simply telling the class to do something. you dont really expect that to fail. however its a question if you also want to throw an exception if you simply didnt have the permissions to connect..
for b)
a failed login() shouldnt throw an exception. since you are actually asking a question: may he login .. possible answers are yes and no.
and so on ..
regards,
Lukas Smith
smith@backendmedia.com
_______________________________
BackendMedia
www.backendmedia.com
berlin@backendmedia.com
Linn Zwoch Smith GbR
Pariser Str. 44
D-10707 Berlin
Tel +49 30 83 22 50 00
Fax +49 30 83 22 50 07