Eric Mann and Mika Toppa have been creating a interesting conversation about the use of the Singleton pattern within WordPress plugins. Eric started it with his article in defense of the pattern, and then Mike wrote a thoughtful response. Both make compelling cases for their position, and both avoid the teenage dickery that often accompanies these types of debates. The comments on each post are informative, too.
I’m personally a fan of the singleton because of the assurance it provides that a class will never be instantiated twice, but I think Mike makes some good points about the practical necessity of doing that, and some alternative ways to achieve it.
I’m currently debating whether or not I really need to continue using singletons in my own plugins, so it’s great to hear more experienced developers fleshing out the finer points of it.