<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Thu, 23 May 2013 21:41:55 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Giorgio Sironi's Blog: How to eliminate singletons]]></title>
      <guid>http://www.phpdeveloper.org/news/13566</guid>
      <link>http://www.phpdeveloper.org/news/13566</link>
      <description><![CDATA[<p>
<i>Giorgio Sironi</i> has posted a <a href="http://giorgiosironi.blogspot.com/2009/11/how-to-eliminate-singletons.html">two</a> <a href="http://giorgiosironi.blogspot.com/2009/11/how-to-eliminate-singletons-part-2.html?">part</a> 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).
</p>
<blockquote>
It is actually very simple to eliminate singletons: just <a href="http://giorgiosironi.blogspot.com/2009/07/never-write-same-code-twice-dependency.html">force the components to ask for what they need</a> 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.
</blockquote>
<p>
In <a href="http://giorgiosironi.blogspot.com/2009/11/how-to-eliminate-singletons.html">the first part</a> 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 <a href="http://giorgiosironi.blogspot.com/2009/11/how-to-eliminate-singletons-part-2.html">second part</a> he refines it down a bit more and only inject/create the objects and resources as needed.
</p>]]></description>
      <pubDate>Thu, 19 Nov 2009 13:05:11 -0600</pubDate>
    </item>
  </channel>
</rss>
