Re: Re: OOP question
| From: | Ammar Ibrahim | Date: | Wed, 31 Aug 2005 12:52:33 +0000 |
| Subject: | Re: Re: OOP question | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-39655@lists.php.net to get a copy of this message | ||
Lukas Smith wrote:
Ammar Ibrahim wrote:$a =& Log::factory( 'Database' ); $b =& Log::factory( 'LDAP' ); $c =& Log::factory( 'Database' ); So the behaviour would be that $a & $c are the same object, but $c isn't. I don't know if this is a standard design pattern, as it implements singleton( Only for the same factory driver ). AmmarSo "normally" a Singleton should return null if no instance if the given object was created yet? Sounds fairly impractical. I think some of the Singleton implementations in PEAR even go so far as to completly ignore instances created directly or via a factory and since the static var they store the instance in as scoped inside the singleton method. regards, Lukas No this is not what I meant. Simply a singleton can be created from a standalone class( one that does not implement a factory ). But having a factory that returns a singleton object can get quite complex, e.g. Having a single object from a TypeI was under the impression a Singleton always implied a Factory.Not really :) Thanks for the tip, I will check the code