Reply to Re: [PHP] php/mysql object id question..

Your name:

Reply:


Posted by Oliver Grätz on 09/15/05 12:11

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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация