News Feed
Jobs Feed
Sections




Recent Jobs

News Archive
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.

0 comments voice your opinion now!
singletons eliminate zendframework



Similar Posts

Federico Cargnelutti's Blog: Review: Zend Framework 1.8 Web Application Development

Jim Wynia's Blog: Tracking Accomplishments with PHP, Google Calendar and Zend Framework

PHPEveryDay.com: Zend Framework Tutorials Posted (Sessions)

PHPImpact Blog: From Swift Mailer to Zend_Mail

ElectricToolBox.com: Method chaining with PHP


Community Events









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


zend windows release feature framework performance opinion zendframework developer facebook conference sqlserver extension job podcast symfony microsoft hiphop codeigniter wordpress

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