Hi,

Here's my original method:
public static function getInstance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }

and I changed it to:

public static function getInstance()
    {
        return new self();
    }

Maybe the method name still implies to singleton?

Marko


Peter Warnock-2 wrote:
> 
> On Tue, Jul 21, 2009 at 10:53 AM, Marko Korhonen <
> [email protected]> wrote:
> 
>>
>> Thanks fo everybody for the great comments!
>>
>> I decided to change my getInstance() method so it just
>> created new instance of the class and returns it (giving up on singleton
>> on this case).
>>
>> So if I have static call:
>> $model = Comment_Model_Comment::getInstance();
>> it's the same if I would write:
>> $model = new Comment_Model_Comment();
>>
>> Only difference being that I can call directly some methods like:
>> $comments = Comment_Model_Comment::getInstance()->getAll();
>>
>> Any considerations to this one?
>>
>> getInstance implies it is a Singleton. You are describing a factory
>> method.
> 
> - pw
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Models-as-Singletons-tp24575704p24595370.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to