Re: Exception misinformation
| From: | David Costa | Date: | Tue, 06 Jul 2004 21:30:56 +0000 |
| Subject: | Re: Exception misinformation | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-31675@lists.php.net to get a copy of this message | ||
On Jul 6, 2004, at 9:37 PM, Hans_L wrote:
There seems to be a lot of (m|d)isinformation about Exceptions on this list. I urge those of you involved in these discussions about Exceptions to actually try using them -- build an application with them. I have used exceptions, PEAR_Error, and other stack-based approaches in PHP and I am not using Exceptions because they are a "trend", but because they have helped me solve patterns faster, write cleaner code, and better handle errors. Here's an attempt to correct what I feel are bits of misinformation from recent discussions.Snip I was initially against exceptions, this was because I never used/tried them. I spent some time with Hans new PHP 5 package and Cox PEAR_Exception draft and several hours later I realized why exceptions are now part of PHP 5 new object model. Whilst I do appreciate the concern of few developers, I also think that there is not enough clarity on this topic. This is already part of PHP 5, like it or not e.g. Sqlite has an in-build OO interface (not document yet ...:D) e.g. new SQLiteDatabase equals to the procedural function sqlite_open $obj->queryExec(...) is like the procedural function sqlite_exec etc. Well if you do something like $db = new SqliteDatabase ('blah.sqlite'); and the db doesn't exist ...and you don't try and catch you will end up with an uncaught exception that will raise a fatal error. This was introduced in PHP 5 as a default OO handler so I don't think they did it the wrong way ;) you might disagree, not like it etc. but this is PHP 5. As Hans said you can it is your job to catch them and this leads to better programming. I just have the weird impressions that some of the people against exceptions are incidentally not very positive on PHP 5 only packages now ... ;) I do believe that they never tried using exceptions or developed something substantial in PHP 5. I am very willing to change my mind again (and of course adapt my standards to the majority if a decision is taken) but I would really prefer to listen to an argument which derives from first hand experience using exceptions and not an assumption that "if I use them in this application this might eventually screw everything...". So, if someone is against using Exceptions and suggest to use ErrorStack in lieu of the new PHP 5 object model that's very fine but I would really like to know when he used Exceptions and how much time he spent on PHP 5. Eventually the "users won't know how to catch exceptions" argument it totally flawed. If they don't, they probably never used PHP 5 (or never used it extensively) therefore they will have little if no interest in PHP 5 only packages. I think the best would be to leave a bit more freedom to the PHP 5 only developers till we have a PHP 5 stable release and obviously a more extended PHP 5 users base. Cheers David Costa