NYCPHP Meetup

NYPHP.org

[nycphp-talk] Are Singletons Really Evil?

Anthony W. ant92083 at gmail.com
Mon Mar 19 11:54:40 EDT 2012


I think the "evil" association comes from exactly what you said, people 
getting burned.  However I feel that singleton's do have use.  For 
example a log file, you only really need one instance for example.  
However there are a couple of reasons why I would argue against 
implementing a singleton:

1.) resource usage for the life of the application
2.) thread issues (not really an issue in PHP)
3.) is this the only way, how about exposure via an interface?

Here are reasons why I argue for implementing a singleton:

1.) they describe a unique resource of the application
2.) global data is sometimes necessary
3.) limit abuse of finite system resources

I could go on all day about this but I would like to hear other arguments.

-- 
Anthony W.
ant92083 at gmail.com




More information about the talk mailing list