You are here: Re: instantiating an object fails (design patterns) « All PHP « IT news, forums, messages
Re: instantiating an object fails (design patterns)

Posted by Oli Filth on 09/16/05 21:00

www.douglassdavis.com said the following on 16/09/2005 15:48:
> Colin McKinnon wrote:
>
>
>>>Let's say an invalid string is passed to construct it. What is the
>>>appropriate way to handle this? I know in Java I would probably throw
>>>an exception, but I don't know how much people really use exceptions in
>>>PHP right now. So, I don't want to depend on it.
>>>
>>
>>This seems an odd thing to say.
>
>
>
> Maybe if I explain, it will not seem so odd to you anymore. I am
> creating a library for others to use, and many people do not use PHP5.
> So, it's kind of a tradeoff as far as using new features vs. being
> usable by every one.
>

Signalling constructor failure using exceptions is the most common
design pattern in a lot of OO languages, e.g. C++ and Java.

The fact that PHP 4 doesn't have exceptions is just one example of how
half-arsed the OO in PHP 4 is.

If you want to make a "serious" OO application, I'd recommend moving to
PHP 5, as PHP 4 doesn't have:

* accessibility modifiers (i.e. public, protected, private)

* abstract modifier

* interfaces

* static members

* exceptions

Now obviously, you don't *need* these things, but they're all extremely
useful tools to help the programmer; without them OO programming is
really cruddy.


--
Oli

 

Navigation:

[Reply to this 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

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