<?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: How and when to use Singleton classes</title>
	<atom:link href="http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/</link>
	<description></description>
	<lastBuildDate>Thu, 10 May 2012 11:05:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Gk</title>
		<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/comment-page-1/#comment-685</link>
		<dc:creator>Gk</dc:creator>
		<pubDate>Thu, 16 Feb 2012 12:57:13 +0000</pubDate>
		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=4#comment-685</guid>
		<description>Nice Post man..keep it up</description>
		<content:encoded><![CDATA[<p>Nice Post man..keep it up</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ajay</title>
		<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/comment-page-1/#comment-676</link>
		<dc:creator>Ajay</dc:creator>
		<pubDate>Tue, 07 Feb 2012 17:58:24 +0000</pubDate>
		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=4#comment-676</guid>
		<description>I am surpised you have published this version of Singleton implementation, while elsewhere in your site, you talk about menotring Junior programmers.  This is exactly the kind of errors inexpereinced programmers make.</description>
		<content:encoded><![CDATA[<p>I am surpised you have published this version of Singleton implementation, while elsewhere in your site, you talk about menotring Junior programmers.  This is exactly the kind of errors inexpereinced programmers make.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: samath jain</title>
		<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/comment-page-1/#comment-642</link>
		<dc:creator>samath jain</dc:creator>
		<pubDate>Mon, 26 Sep 2011 13:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=4#comment-642</guid>
		<description>This is very useful article.</description>
		<content:encoded><![CDATA[<p>This is very useful article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shiv mohan</title>
		<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/comment-page-1/#comment-636</link>
		<dc:creator>shiv mohan</dc:creator>
		<pubDate>Mon, 12 Sep 2011 20:22:08 +0000</pubDate>
		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=4#comment-636</guid>
		<description>Can you give me a example where you actually need to save state of singleton instance.</description>
		<content:encoded><![CDATA[<p>Can you give me a example where you actually need to save state of singleton instance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KS</title>
		<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/comment-page-1/#comment-629</link>
		<dc:creator>KS</dc:creator>
		<pubDate>Sat, 06 Aug 2011 15:20:40 +0000</pubDate>
		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=4#comment-629</guid>
		<description>This is a very useful article. Thanks for posting.</description>
		<content:encoded><![CDATA[<p>This is a very useful article. Thanks for posting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: any</title>
		<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/comment-page-1/#comment-628</link>
		<dc:creator>any</dc:creator>
		<pubDate>Fri, 05 Aug 2011 08:54:16 +0000</pubDate>
		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=4#comment-628</guid>
		<description>As you can see, the state of these methods don’t matter. You just want to use them to perform a simple task for you. But if you coding your application and you are using a central object where state does matter(such as the ModelLocator example), then its best to use a Singleton.

The next reason you may want to use a Singleton is if it is a particularly “heavy” object. If your object is large and takes up a reasonable amount of memory, you probably only one of those objects floating around. This is the case for things like a if you have a factory method that is particularly robust, you want to make sure that its not going to be instantiated multiple times. A Singleton class will help prevent such the case ever happening.

The Singleton is a simple and powerful design pattern. Newer programmers may not realize what potential it has and will over look it. Others may love it so much and end of overusing it in the wrong way. Hopefully this article was helpful for you. If so, let me know! Leave a comment or email me at marcel@codeofdoom.com</description>
		<content:encoded><![CDATA[<p>As you can see, the state of these methods don’t matter. You just want to use them to perform a simple task for you. But if you coding your application and you are using a central object where state does matter(such as the ModelLocator example), then its best to use a Singleton.</p>
<p>The next reason you may want to use a Singleton is if it is a particularly “heavy” object. If your object is large and takes up a reasonable amount of memory, you probably only one of those objects floating around. This is the case for things like a if you have a factory method that is particularly robust, you want to make sure that its not going to be instantiated multiple times. A Singleton class will help prevent such the case ever happening.</p>
<p>The Singleton is a simple and powerful design pattern. Newer programmers may not realize what potential it has and will over look it. Others may love it so much and end of overusing it in the wrong way. Hopefully this article was helpful for you. If so, let me know! Leave a comment or email me at <a href="mailto:marcel@codeofdoom.com">marcel@codeofdoom.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: any</title>
		<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/comment-page-1/#comment-627</link>
		<dc:creator>any</dc:creator>
		<pubDate>Fri, 05 Aug 2011 08:53:09 +0000</pubDate>
		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=4#comment-627</guid>
		<description>When you do this, the getInstance() method then checks to see if the parameter ‘instance’ is null. If it is, it will create a new one by calling the private constructor. After that, it just returns it. Of course, if it is not null, it just returns the existing instance of it. This insures that there is only one copy of the object within your program.

Of course, this post wouldn’t have much meat to it if thats what I left it at. So lets talk about some of the uses of a Singleton class. Also you might at some point as ‘why not just make it static?’, which is a common question, so I will go over that about that as well.

First, what are the uses of a Singleton?. Singleton classes are normally used for things such as a Factory classes, Builder classes and things like that. A few real world examples include the the SessionFactory class in Hibernate – it’s actually a singleton. Or with log4j, when you call its logger, it uses a singleton class to return it. If anyone has used Cairngorm within Flex/Actionscript 3, its model locator is a Singleton.</description>
		<content:encoded><![CDATA[<p>When you do this, the getInstance() method then checks to see if the parameter ‘instance’ is null. If it is, it will create a new one by calling the private constructor. After that, it just returns it. Of course, if it is not null, it just returns the existing instance of it. This insures that there is only one copy of the object within your program.</p>
<p>Of course, this post wouldn’t have much meat to it if thats what I left it at. So lets talk about some of the uses of a Singleton class. Also you might at some point as ‘why not just make it static?’, which is a common question, so I will go over that about that as well.</p>
<p>First, what are the uses of a Singleton?. Singleton classes are normally used for things such as a Factory classes, Builder classes and things like that. A few real world examples include the the SessionFactory class in Hibernate – it’s actually a singleton. Or with log4j, when you call its logger, it uses a singleton class to return it. If anyone has used Cairngorm within Flex/Actionscript 3, its model locator is a Singleton.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ankur</title>
		<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/comment-page-1/#comment-455</link>
		<dc:creator>Ankur</dc:creator>
		<pubDate>Sat, 05 Feb 2011 08:03:45 +0000</pubDate>
		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=4#comment-455</guid>
		<description>Awesome explaination. Thanks</description>
		<content:encoded><![CDATA[<p>Awesome explaination. Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MCPHERSONStaci24</title>
		<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/comment-page-1/#comment-382</link>
		<dc:creator>MCPHERSONStaci24</dc:creator>
		<pubDate>Wed, 21 Jul 2010 18:53:46 +0000</pubDate>
		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=4#comment-382</guid>
		<description>Do not cash to buy a car? You not have to worry, because it is possible to get the &lt;a href=&quot;http://bestfinance-blog.com/topics/mortgage-loans&quot; rel=&quot;nofollow&quot;&gt;mortgage loans&lt;/a&gt; to work out such problems. Hence take a collateral loan to buy everything you need.</description>
		<content:encoded><![CDATA[<p>Do not cash to buy a car? You not have to worry, because it is possible to get the <a href="http://bestfinance-blog.com/topics/mortgage-loans" rel="nofollow">mortgage loans</a> to work out such problems. Hence take a collateral loan to buy everything you need.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alzheimers Disease</title>
		<link>http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/comment-page-1/#comment-372</link>
		<dc:creator>Alzheimers Disease</dc:creator>
		<pubDate>Tue, 15 Jun 2010 10:01:55 +0000</pubDate>
		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=4#comment-372</guid>
		<description>Thanks for posting this very helpful information; I happened to come to  your blog just searching around the web. Please keep up the good work!</description>
		<content:encoded><![CDATA[<p>Thanks for posting this very helpful information; I happened to come to  your blog just searching around the web. Please keep up the good work!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

