<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PHP Anti Patterns</title>
	<atom:link href="http://www.thedeveloperday.com/php-anti-patterns/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thedeveloperday.com/php-anti-patterns/</link>
	<description>Staying Curious</description>
	<lastBuildDate>Wed, 01 Feb 2012 07:05:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Somtimes we could learn from the bad practises &#124; Joshy&#039;s microblog</title>
		<link>http://www.thedeveloperday.com/php-anti-patterns/comment-page-1/#comment-1108</link>
		<dc:creator>Somtimes we could learn from the bad practises &#124; Joshy&#039;s microblog</dc:creator>
		<pubDate>Mon, 10 Oct 2011 09:03:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.thedeveloperday.com/?p=572#comment-1108</guid>
		<description>[...] we could learn from the bad practises Posted on 2011. October 10. Monday  by  admin PHP Antipatternshttp://www.thedeveloperday.com/php-anti-patterns/ This entry was posted in Link and tagged php. Bookmark the permalink.  Post navigation&#8592; [...]</description>
		<content:encoded><![CDATA[<p>[...] we could learn from the bad practises Posted on 2011. October 10. Monday  by  admin PHP Antipatternshttp://www.thedeveloperday.com/php-anti-patterns/ This entry was posted in Link and tagged php. Bookmark the permalink.  Post navigation&larr; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Žilvinas Šaltys</title>
		<link>http://www.thedeveloperday.com/php-anti-patterns/comment-page-1/#comment-389</link>
		<dc:creator>Žilvinas Šaltys</dc:creator>
		<pubDate>Wed, 10 Mar 2010 09:48:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.thedeveloperday.com/?p=572#comment-389</guid>
		<description>Paul,

You must agree that singletons are in some way the same global variables which you agree are bad practice.

Then you have to think about tests. While you can still do unit tests with singletons it&#039;s not as straightforward as with dependency injection.

You could also check dependency injection frameworks such as http://components.symfony-project.org/dependency-injection/ which might make it a lot more easier to instantiate your application objects without always passing dependencies.

How you instantiate objects in controllers doesn&#039;t matter much. For example most of the older Zend Framework code will use Registries. The new generation may use DI containers or resource loaders.

Misko Hevery has written a lot about singletons, testing and global state. You might be interested to check his blog: http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/</description>
		<content:encoded><![CDATA[<p>Paul,</p>
<p>You must agree that singletons are in some way the same global variables which you agree are bad practice.</p>
<p>Then you have to think about tests. While you can still do unit tests with singletons it&#8217;s not as straightforward as with dependency injection.</p>
<p>You could also check dependency injection frameworks such as <a href="http://components.symfony-project.org/dependency-injection/" rel="nofollow">http://components.symfony-project.org/dependency-injection/</a> which might make it a lot more easier to instantiate your application objects without always passing dependencies.</p>
<p>How you instantiate objects in controllers doesn&#8217;t matter much. For example most of the older Zend Framework code will use Registries. The new generation may use DI containers or resource loaders.</p>
<p>Misko Hevery has written a lot about singletons, testing and global state. You might be interested to check his blog: <a href="http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/" rel="nofollow">http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul G.</title>
		<link>http://www.thedeveloperday.com/php-anti-patterns/comment-page-1/#comment-388</link>
		<dc:creator>Paul G.</dc:creator>
		<pubDate>Wed, 10 Mar 2010 09:07:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.thedeveloperday.com/?p=572#comment-388</guid>
		<description>I am reading your article with great interest. 

I can very much agree with what you say about constantitis, globalomania and god classes, but when it comes to singletons, I can&#039;t find a better solution than using a singleton. Without it I will have to pass important instances as arguments to all classes that needs it. 

Ofcourse, some of the classes that are, and should be loosely coupled, must get a database instance by argument, but for the rest (controller classes and other classes in an application) can just as well get the database instance from the singleton, and pass it as argument to the loosely coupled classes.

Do you have a suggestion for what to do instead of using a singleton?

Paul</description>
		<content:encoded><![CDATA[<p>I am reading your article with great interest. </p>
<p>I can very much agree with what you say about constantitis, globalomania and god classes, but when it comes to singletons, I can&#8217;t find a better solution than using a singleton. Without it I will have to pass important instances as arguments to all classes that needs it. </p>
<p>Ofcourse, some of the classes that are, and should be loosely coupled, must get a database instance by argument, but for the rest (controller classes and other classes in an application) can just as well get the database instance from the singleton, and pass it as argument to the loosely coupled classes.</p>
<p>Do you have a suggestion for what to do instead of using a singleton?</p>
<p>Paul</p>
]]></content:encoded>
	</item>
</channel>
</rss>

