Ok, I might live with that. So what are the main pros using singletons?
- Is there performance gain or memory savings or something like that? - Code syntax benefits? - Something else? Only thing I really understand that it gets always the same instance of the class and does not create new ones. br, Marko Matthew Weier O'Phinney-3 wrote: > > -- Marko Korhonen <marko.korho...@datafisher.com> wrote > (on Monday, 20 July 2009, 12:06 PM -0700): >> I made my Model classes singletons and I'm wondering if there is any >> major >> cons in this solution. > > One major one: Testing. > > I've had to do a lot of testing against singletons, and it's simply not > worth it. It requires hacks for resetting state, and when you have a > test suite where these objects may be used in a number of different > suites, state becomes a tricky proposition. > >> Here's my setup from one on the modules: >> Comment_Model_Comment (Model Comment from Comment module, Singleton) >> Comment_Model_DbTable_Comment (Zend_Db_Table extended class) >> Comment_Model_DbTable_Rowset_Comment (Zend_Db_Table_Rowset extended >> class) >> Comment_Model_DbTable_Row_Comment (Zend_Db_Table_Row extended class) >> >> So I made my Model class as singleton becouse it does not represent >> individual comments. >> It's just one class knowing what to do with comments. >> >> I tried to avoid having too many instances of this model class for vain. >> >> Any comments or questions ? > > -- > Matthew Weier O'Phinney > Project Lead | matt...@zend.com > Zend Framework | http://framework.zend.com/ > > -- View this message in context: http://www.nabble.com/Models-as-Singletons-tp24575704p24586221.html Sent from the Zend Framework mailing list archive at Nabble.com.