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? br, Marko troels knak-nielsen-2 wrote: > > On Tue, Jul 21, 2009 at 1:52 PM, Marko > Korhonen<[email protected]> wrote: >> - Is there performance gain or memory savings or something like that? > > On the contrary. A singleton prevents the garbage collector from > functioning. > >> - Code syntax benefits? > > That's rather subjective. > >> - Something else? > > Low level of abstraction means easy to understand. This is the only > benefit of a singleton. While it's real, it usually doesn't make up > for the high level of coupling it incurs. Ultimately it's a judgement > call, but most experienced programmers wouldn't use them in this > scenario (or at all). > >> Only thing I really understand that it gets always the same instance of >> the >> class >> and does not create new ones. > > If you don't fully understand the implications of singletons, you > should probably avoid them like the plague. If you *do* understand the > implications of singletons you *will* avoid them like the plague. > > -- > troels > > -- View this message in context: http://www.nabble.com/Models-as-Singletons-tp24575704p24592194.html Sent from the Zend Framework mailing list archive at Nabble.com.
