<?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: Root Cause of Singletons</title>
	<atom:link href="http://misko.hevery.com/2008/08/25/root-cause-of-singletons/feed/" rel="self" type="application/rss+xml" />
	<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/</link>
	<description>Testability Explorer</description>
	<lastBuildDate>Thu, 02 Sep 2010 04:05:01 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Singletons : Is Anti-Pattern? &#171; Technical Jottings</title>
		<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/comment-page-1/#comment-2505</link>
		<dc:creator>Singletons : Is Anti-Pattern? &#171; Technical Jottings</dc:creator>
		<pubDate>Wed, 02 Dec 2009 07:08:24 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=192#comment-2505</guid>
		<description>[...] in few cases and there are some &#8220;cleaner&#8221; ways of achieving singleton benefits.  Here, Misko clearly points that Singletons are useful when there is one way flow in the [...]</description>
		<content:encoded><![CDATA[<p>[...] in few cases and there are some &#8220;cleaner&#8221; ways of achieving singleton benefits.  Here, Misko clearly points that Singletons are useful when there is one way flow in the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Another Architectural Framework, But Why? &#171; shaun smith</title>
		<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/comment-page-1/#comment-928</link>
		<dc:creator>Another Architectural Framework, But Why? &#171; shaun smith</dc:creator>
		<pubDate>Wed, 29 Apr 2009 12:48:29 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=192#comment-928</guid>
		<description>[...] standard Singleton implementation (that static getInstance method) is severely flawed. Unless you are writing device drivers, there is almost no excuse to touch a [...]</description>
		<content:encoded><![CDATA[<p>[...] standard Singleton implementation (that static getInstance method) is severely flawed. Unless you are writing device drivers, there is almost no excuse to touch a [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How to do Everything Wrong with Servlets</title>
		<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/comment-page-1/#comment-853</link>
		<dc:creator>How to do Everything Wrong with Servlets</dc:creator>
		<pubDate>Wed, 08 Apr 2009 18:43:29 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=192#comment-853</guid>
		<description>[...] use global state and singletons for inter servlet communication (which we have covered in detailed here, here, and [...]</description>
		<content:encoded><![CDATA[<p>[...] use global state and singletons for inter servlet communication (which we have covered in detailed here, here, and [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AS3 Dependency Injection and [Autowire] &#171; shaun smith</title>
		<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/comment-page-1/#comment-806</link>
		<dc:creator>AS3 Dependency Injection and [Autowire] &#171; shaun smith</dc:creator>
		<pubDate>Thu, 26 Mar 2009 11:42:09 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=192#comment-806</guid>
		<description>[...] Alternatively, you could use a Singleton to hang all your objects on. That would not be cool: link, link, link. [...]</description>
		<content:encoded><![CDATA[<p>[...] Alternatively, you could use a Singleton to hang all your objects on. That would not be cool: link, link, link. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/comment-page-1/#comment-722</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Tue, 24 Feb 2009 15:53:59 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=192#comment-722</guid>
		<description>@Chris,

no, the issue I have with singletons is that they represent global state. You can call them whatever you want but the moment you access any abject through a global variable you will have an issue with testability and maintainability of the code. Moreover the globality is transitive, so once you get a hold of a global variable anything you can get a hold of from there is global as well. A single global variable can expose a large mutable state to an application which is global.</description>
		<content:encoded><![CDATA[<p>@Chris,</p>
<p>no, the issue I have with singletons is that they represent global state. You can call them whatever you want but the moment you access any abject through a global variable you will have an issue with testability and maintainability of the code. Moreover the globality is transitive, so once you get a hold of a global variable anything you can get a hold of from there is global as well. A single global variable can expose a large mutable state to an application which is global.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hopman</title>
		<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/comment-page-1/#comment-721</link>
		<dc:creator>Chris Hopman</dc:creator>
		<pubDate>Tue, 24 Feb 2009 09:13:23 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=192#comment-721</guid>
		<description>Whatever is absolutely correct. You have a problem with a particular Singleton implementation, not the Singleton design pattern. I&#039;m going to assume that you don&#039;t know the difference rather than that you are deliberately setting up a straw man.So, basically your Singleton implementation  can be used as follows:singleton.init();singleton.do_something();That is you have a Singleton instance singleton that must have init() called before it can be used. This seems to be due to your desire for constructors to not actually construct objects. If you want to lazily construct your object, as long as you aren&#039;t directly exposing your internals, there is no need for for users to explicitly do the initialization. In fact, such a requirement smells bad, you should make it difficult for users to misuse your code. Almost all implementations I&#039;ve seen require you to call a method to get a reference to the singleton instance. In this method, init() is called if needed. With this pattern, the singleton instance can even expose its internals without worry of them not being initialized. That is, the above code would change tosingleton::instance().do_something();If you don&#039;t want the instance() method, then as long as initialization is checked and done in each of the singleton&#039;s methods and it doesn&#039;t expose its internals you can have the interface that you wanted. That is, you could do:singleton.do_something();Either of these solutions completely solve your original complaint about the Singleton design pattern. Again, it seems your problem is with a particular implementation that with the pattern itself.</description>
		<content:encoded><![CDATA[<p>Whatever is absolutely correct. You have a problem with a particular Singleton implementation, not the Singleton design pattern. I&#8217;m going to assume that you don&#8217;t know the difference rather than that you are deliberately setting up a straw man.So, basically your Singleton implementation  can be used as follows:singleton.init();singleton.do_something();That is you have a Singleton instance singleton that must have init() called before it can be used. This seems to be due to your desire for constructors to not actually construct objects. If you want to lazily construct your object, as long as you aren&#8217;t directly exposing your internals, there is no need for for users to explicitly do the initialization. In fact, such a requirement smells bad, you should make it difficult for users to misuse your code. Almost all implementations I&#8217;ve seen require you to call a method to get a reference to the singleton instance. In this method, init() is called if needed. With this pattern, the singleton instance can even expose its internals without worry of them not being initialized. That is, the above code would change tosingleton::instance().do_something();If you don&#8217;t want the instance() method, then as long as initialization is checked and done in each of the singleton&#8217;s methods and it doesn&#8217;t expose its internals you can have the interface that you wanted. That is, you could do:singleton.do_something();Either of these solutions completely solve your original complaint about the Singleton design pattern. Again, it seems your problem is with a particular implementation that with the pattern itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Witold Szczerba</title>
		<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/comment-page-1/#comment-687</link>
		<dc:creator>Witold Szczerba</dc:creator>
		<pubDate>Sun, 15 Feb 2009 22:57:07 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=192#comment-687</guid>
		<description>Thank you Misko for great blog. I have never heard anyone explaining the difficult things you say like this. I just read it and it hits me like a thunder: &quot;damn, he has got the point just-like-that while I couldn&#039;t find it for long time&quot; :)Keep dooing your great job, do not worry because all those guys who does not get the idea.</description>
		<content:encoded><![CDATA[<p>Thank you Misko for great blog. I have never heard anyone explaining the difficult things you say like this. I just read it and it hits me like a thunder: &#8220;damn, he has got the point just-like-that while I couldn&#8217;t find it for long time&#8221; <img src='http://misko.hevery.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Keep dooing your great job, do not worry because all those guys who does not get the idea.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Pinstein</title>
		<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/comment-page-1/#comment-544</link>
		<dc:creator>Alan Pinstein</dc:creator>
		<pubDate>Wed, 07 Jan 2009 19:37:46 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=192#comment-544</guid>
		<description>Misko-Thanks for all of these posts and your Google Clean Code talks. I watched those first, and while I was convinced of the need to do as you explained, I didn&#039;t see HOW. This series of blog posts with concrete examples has definitely helped me see ways to refactor away from Singletons. Thanks,Alan</description>
		<content:encoded><![CDATA[<p>Misko-Thanks for all of these posts and your Google Clean Code talks. I watched those first, and while I was convinced of the need to do as you explained, I didn&#8217;t see HOW. This series of blog posts with concrete examples has definitely helped me see ways to refactor away from Singletons. Thanks,Alan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Interfacing with hard-to-test third-party code</title>
		<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/comment-page-1/#comment-526</link>
		<dc:creator>Interfacing with hard-to-test third-party code</dc:creator>
		<pubDate>Sun, 04 Jan 2009 19:30:33 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=192#comment-526</guid>
		<description>[...] notice that the no argument constructor is forcing me to use global state, which is very bad, but in the case of servlets I have no choice.  However, I make sure that only [...]</description>
		<content:encoded><![CDATA[<p>[...] notice that the no argument constructor is forcing me to use global state, which is very bad, but in the case of servlets I have no choice.  However, I make sure that only [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Phantom Inspector &#187; Recording and validating NSNotifications in Objective-C Unit Tests</title>
		<link>http://misko.hevery.com/2008/08/25/root-cause-of-singletons/comment-page-1/#comment-501</link>
		<dc:creator>The Phantom Inspector &#187; Recording and validating NSNotifications in Objective-C Unit Tests</dc:creator>
		<pubDate>Sun, 21 Dec 2008 22:49:32 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=192#comment-501</guid>
		<description>[...] NSNotificationCenter is basically a global context which is used by many classes. As Miško Hevery points out, global state makes testing hard. So if I decided to be pedantic about avoiding global state and [...]</description>
		<content:encoded><![CDATA[<p>[...] NSNotificationCenter is basically a global context which is used by many classes. As Miško Hevery points out, global state makes testing hard. So if I decided to be pedantic about avoiding global state and [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
