Re: php/mysql object id question..
| From: | Oliver Grätz | Date: | Thu, 15 Sep 2005 09:11:43 +0000 |
| Subject: | Re: php/mysql object id question.. | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-222465@lists.php.net to get a copy of this message | ||
Jasper Bryant-Greene schrieb:
> Oliver Grätz wrote:
>
>>3. Yes. One can abuse exceptions to return something in a constructor.
>> Just another argument against exceptions ;-) OK, it's unorthodox,
>> if you absolutely need to do that, do it and tell nobody *g*.
>
> This is not "abusing" exceptions. If you throw an exception then the
> expected behaviour should be that the following code should not be
> executed [1].
If you throw the exception for error purpose it's OK, but if you throw
the exception just for the purpose of returning a value then it's abuse.
That's what I meant.
> Throwing an exception inside a constructor will prevent the object from
> being created. It will not allow you to "return something" of your
> choice -- I haven't tested but I would expect that the variable you were
> setting as the object would either remain unset or would be set to NULL.
Tested. non-object. At least this is as expected ;-)
> I'm not too sure why you said "just another argument against exceptions"
> (apart from perhaps a lack of understanding) as exceptions are a very
> useful feature in any language.
Sorry I didn't mark this as personal opinion (just like all the rest).
Exceptions make good programming more difficult without need. Raymond
Chen wrote this about exceptions:
http://blogs.msdn.com/oldnewthing/archive/2005/1/14.aspx
AllOLLi
____________
This time it will surely run.