On 21 Jul 2009, at 18:49, till wrote:
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!)
None taken ;-) I'm definitely not a very skilled programmer but I'd argue that using singletons can just be a case of getting on with the job at hand. Even accepting that it makes testing harder, using singletons can be simpler overall.
In particular, in relatively small applications with a known scope/ domain (the average professional PHP developer's bread-and-butter) knocking up a singleton version of key resources (those that may be needed anywhere) is so quick and easy that the trade off against some shared fixtures in the test suite is no problem.
Regards, Carlton
