News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Michael Girouard's Blog:
One Step Closer to an Abstract Singleton
November 27, 2007 @ 09:37:00

Michael Girouard has pointed out that things in the PHP world are one step closer to being able to create an abstract Singleton object via a simple script he's shared.

The singleton is an incredibly useful pattern in PHP for many reasons. I tend to find myself using them when I know I should be using static classes, but can't because of PHP's lack of proper class name discovery in extended static classes.

[...] And that works like a charm every time. The problem is, in one application there may be several classes that need to be singletons. In which case my first thought was to build an abstract singleton.

Unfortunately, it didn't quite work like he'd thought it would. He did, however, come up with something that did work - creating an interface and making an abstract implementation of it (code example for this included).

0 comments voice your opinion now!
abstract singleton designpattern implements interface abstract singleton designpattern implements interface


blog comments powered by Disqus

Similar Posts

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 9)

PHPMaster.com: An Introduction to the Front Controller Pattern, Part 2

PHPMaster.com: Manage Complexity with the Facade Pattern

Matthew Weir O'Phinney's Blog: Cgiapp2 Tutorial 1 - Switch Template Plugins at Will

Chris Hartjes' Blog: Fat Models, Skinny Controllers


Community Events





Don't see your event here?
Let us know!


list community release introduction library symfony install laravel tips api framework podcast interview voicesoftheelephpant opinion bugfix language deployment series package

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework