<?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: Flaw: Brittle Global State &amp; Singletons</title>
	<atom:link href="http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/feed/" rel="self" type="application/rss+xml" />
	<link>http://misko.hevery.com</link>
	<description>Testability Explorer</description>
	<lastBuildDate>Fri, 30 Jul 2010 03:59:03 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Refactoring static calls and global variables from an object &#124; Alternate Illusion</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/comment-page-1/#comment-3038</link>
		<dc:creator>Refactoring static calls and global variables from an object &#124; Alternate Illusion</dc:creator>
		<pubDate>Sat, 06 Feb 2010 12:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=328#comment-3038</guid>
		<description>[...] What&#8217;s wrong with globals?  Accessing global state statically doesn’t clarify those shared dependencies to readers of the constructors and methods that use the Global State. Global State and Singletons make APIs lie about their true dependencies. To really understand the dependencies, developers must read every line of code. It causes Spooky Action at a Distance: when running test suites, global state mutated in one test can cause a subsequent or parallel test to fail unexpectedly. Misko Hevery: Flaw: Brittle Global State &amp; Singletons [...]</description>
		<content:encoded><![CDATA[<p>[...] What&#8217;s wrong with globals?  Accessing global state statically doesn’t clarify those shared dependencies to readers of the constructors and methods that use the Global State. Global State and Singletons make APIs lie about their true dependencies. To really understand the dependencies, developers must read every line of code. It causes Spooky Action at a Distance: when running test suites, global state mutated in one test can cause a subsequent or parallel test to fail unexpectedly. Misko Hevery: Flaw: Brittle Global State &amp; Singletons [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/comment-page-1/#comment-2993</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Thu, 28 Jan 2010 17:51:28 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=328#comment-2993</guid>
		<description>@David,

I am not proposing to have more instances or consume memory. Whether you write you application with Global state (Singleton) or with dependency injection (where you have single instance of a class). You have the same number of objects and hence the same memory consumption. The question at the table is not how many instances of objects you have as that is fixed by the application design, but how do these objects get to where they need to be: 1) Global state (bad) or 2) passed in through the constructor (good)</description>
		<content:encoded><![CDATA[<p>@David,</p>
<p>I am not proposing to have more instances or consume memory. Whether you write you application with Global state (Singleton) or with dependency injection (where you have single instance of a class). You have the same number of objects and hence the same memory consumption. The question at the table is not how many instances of objects you have as that is fixed by the application design, but how do these objects get to where they need to be: 1) Global state (bad) or 2) passed in through the constructor (good)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/comment-page-1/#comment-2991</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Thu, 28 Jan 2010 17:47:09 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=328#comment-2991</guid>
		<description>@Jobob,

this is a very strange question, since the performance of application has nothing to do wether you have a singleton or not. In both case you have same number of objects, the question is not how many objects you have or what is the performance, but how do the references of the objects get to where they need to be. A) Global state, B) passed in through constructor.</description>
		<content:encoded><![CDATA[<p>@Jobob,</p>
<p>this is a very strange question, since the performance of application has nothing to do wether you have a singleton or not. In both case you have same number of objects, the question is not how many objects you have or what is the performance, but how do the references of the objects get to where they need to be. A) Global state, B) passed in through constructor.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/comment-page-1/#comment-2987</link>
		<dc:creator>David</dc:creator>
		<pubDate>Thu, 28 Jan 2010 05:06:45 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=328#comment-2987</guid>
		<description>In interpreted scripting languages like PHP you quickly find that process can eat through several megabytes of memory if you are not careful with your objects and variables. This has lead many PHP developers down the path of singleton in an effort to save memory. 

So depending on the language singleton might be the best way to increase application speed while making testing more difficult. (I&#039;m thinking of a logging or caching class here).

However, it is also a waste of memory to keep objects in memory when they are not needed - which is what a singleton does and, as you state, it also make the code much more spooky than it needs to be.

So I can&#039;t quite give up the idea of all losing all singletons (in PHP) but they defiantly shouldn&#039;t be the norm.</description>
		<content:encoded><![CDATA[<p>In interpreted scripting languages like PHP you quickly find that process can eat through several megabytes of memory if you are not careful with your objects and variables. This has lead many PHP developers down the path of singleton in an effort to save memory. </p>
<p>So depending on the language singleton might be the best way to increase application speed while making testing more difficult. (I&#8217;m thinking of a logging or caching class here).</p>
<p>However, it is also a waste of memory to keep objects in memory when they are not needed &#8211; which is what a singleton does and, as you state, it also make the code much more spooky than it needs to be.</p>
<p>So I can&#8217;t quite give up the idea of all losing all singletons (in PHP) but they defiantly shouldn&#8217;t be the norm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jobob</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/comment-page-1/#comment-2985</link>
		<dc:creator>jobob</dc:creator>
		<pubDate>Thu, 28 Jan 2010 01:02:13 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=328#comment-2985</guid>
		<description>have you done any benchmarks against a singleton based application and a test based application?</description>
		<content:encoded><![CDATA[<p>have you done any benchmarks against a singleton based application and a test based application?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Einführung in TDD &#38; Clean Code Talks &#124; geekcloud.org</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/comment-page-1/#comment-2431</link>
		<dc:creator>Einführung in TDD &#38; Clean Code Talks &#124; geekcloud.org</dc:creator>
		<pubDate>Sun, 22 Nov 2009 15:25:02 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=328#comment-2431</guid>
		<description>[...] Flaw #3: Brittle Global State &amp; Singletons [...]</description>
		<content:encoded><![CDATA[<p>[...] Flaw #3: Brittle Global State &amp; Singletons [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: All About Google &#187; How to think about OO</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/comment-page-1/#comment-2022</link>
		<dc:creator>All About Google &#187; How to think about OO</dc:creator>
		<pubDate>Tue, 06 Oct 2009 06:42:16 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=328#comment-2022</guid>
		<description>[...] in OO world. I can already hear the screams, so let me explain why, but first we need to agree that global variables and state is evil. If you agree with previous statement than for a static method to do something interesting it needs [...]</description>
		<content:encoded><![CDATA[<p>[...] in OO world. I can already hear the screams, so let me explain why, but first we need to agree that global variables and state is evil. If you agree with previous statement than for a static method to do something interesting it needs [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petroglyphs &#187; Blog Archive &#187; Kool-Aid, drinking the</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/comment-page-1/#comment-1585</link>
		<dc:creator>Petroglyphs &#187; Blog Archive &#187; Kool-Aid, drinking the</dc:creator>
		<pubDate>Tue, 11 Aug 2009 04:33:04 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=328#comment-1585</guid>
		<description>[...] code, stuff that&#8217;s been written in the last few months (not by me) which is full of global state and complex un-mockable setup. Most of that has been scattershot/mercenary work to make life easier [...]</description>
		<content:encoded><![CDATA[<p>[...] code, stuff that&#8217;s been written in the last few months (not by me) which is full of global state and complex un-mockable setup. Most of that has been scattershot/mercenary work to make life easier [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/comment-page-1/#comment-1530</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Wed, 05 Aug 2009 21:29:54 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=328#comment-1530</guid>
		<description>@Paul,

CL stands for change list. (or a patch which is submitted to your version control)</description>
		<content:encoded><![CDATA[<p>@Paul,</p>
<p>CL stands for change list. (or a patch which is submitted to your version control)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: paul</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/comment-page-1/#comment-1529</link>
		<dc:creator>paul</dc:creator>
		<pubDate>Wed, 05 Aug 2009 20:07:39 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=328#comment-1529</guid>
		<description>misko, great stuff as always. quick question, what does CL stand for in your symptoms section?</description>
		<content:encoded><![CDATA[<p>misko, great stuff as always. quick question, what does CL stand for in your symptoms section?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
