Andrey Hristov <[EMAIL PROTECTED]> writes:

>  Why not using Singleton for multiple objects with getInstance() ?

Yeah, it's not quite a Singleton pattern.  I've seen references to what I'm
talking about as a Pool pattern.  That's basically what I described here:

>> One could certainly call a function which searched for the key value and
>> only instantiated a new object if the existing one was not found, but this
>> seems cleaner.

There are absolutely ways to do this purely at the application level.  It just
seems that it'd be a really clean, easy to program, easy to understand
methodology to pass the key value to the request for a new instance, and get
back either a new instance, or a previously existing one with that key value.

In fact, the proposed __new() feature could provide an automatic Singleton
capability without the caller needing to worry about (or even know) that it's
dealing with a Singleton.  The class defines a __new() function that always
returns its one and only instance (instantiating it the very first time), and
the application can always use 'new' without worrying about the internal
implementation.

Derrell

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to