News Feed
Sections




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

Giorgio Sironi's Blog:
How to eliminate singletons
November 19, 2009 @ 13:05:11

Giorgio Sironi has posted a two part look at some techniques you can use to eliminate the singletons scattered through out your code (as sparked by the recent announcement that the Zend Framework project will be doing the same thing).

It is actually very simple to eliminate singletons: just force the components to ask for what they need in the constructor or via setters or via inject*() methods, instead of looking up a singleton trough a static method only to obtain a reference. Once this fundamental decoupling is achieved, the hard part is tackling the construction problem.

In the first part of the two, he looks at a Zend Framework example of how to replace a certain piece of code with injected instances of required objects. In the second part he refines it down a bit more and only inject/create the objects and resources as needed.

1 comment voice your opinion now!
singletons eliminate zendframework


blog comments powered by Disqus

Similar Posts

Matthew Weier O'Phinney's Blog: Exposing Service APIs via Zend Framework

ProDevTips.com: Ajax, ZF and Smarty feed reader - part 1

Padraic Brady's Blog: The PHPSpec Zend Framework App Testing Manifesto: ZF Integration

Jani Hartikainen's Blog: Integrating FCKeditor with Zend_Form

Rob Allen's Blog: Tutorial Notes - Zend_Auth in French & Using Oracle


Community Events





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


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

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