-- 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/