On Tue, Jul 21, 2009 at 7:43 PM, Michael Irey<[email protected]> wrote: > > On 7/21/09 4:52 AM, "Marko Korhonen" <[email protected]> wrote: >> - Is there performance gain or memory savings or something like that? > > I don't remember who, but someone on ZFChat had recommended using Factory > for zend_db_table objects to give a performance boost on the application. > After reading this thread, we ran a few tests to see what the actual > performance boost is and it does seem significant. > > Here is what we are using for our Factory: > http://pastie.org/553707
http://en.wikipedia.org/wiki/Singleton_pattern What you have a is a singleton. A factory pattern is used to create objects, see here: http://en.wikipedia.org/wiki/Factory_method_pattern Generally, what Matthew stated is super-correct. The singleton makes testing harder, as does everything static because it's hard to "reset" the state. People use singletons because the so-called business logic demands, or more often because they are not very skilled programmers. ;-) (No offense meant!) There are other ways to make sure you are only using a single instance of the same object. Forcing the same behaviour in code is absurd because that means that you're working around of the short comings of the people using it. The performance gain in your example comes from re-using the object. Not from using a design pattern. Till
