<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: What is the better approach to implement Singleton pattern?</title>
	<atom:link href="http://webmoli.com/2008/03/27/what-is-the-better-approach-to-implement-singleton-pattern/feed/" rel="self" type="application/rss+xml" />
	<link>http://webmoli.com/2008/03/27/what-is-the-better-approach-to-implement-singleton-pattern/</link>
	<description></description>
	<lastBuildDate>Tue, 24 Jan 2012 14:36:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: mohanmca</title>
		<link>http://webmoli.com/2008/03/27/what-is-the-better-approach-to-implement-singleton-pattern/#comment-312</link>
		<dc:creator><![CDATA[mohanmca]]></dc:creator>
		<pubDate>Mon, 26 Jan 2009 17:08:08 +0000</pubDate>
		<guid isPermaLink="false">http://venkatsadasivam.wordpress.com/?p=52#comment-312</guid>
		<description><![CDATA[I often use Holder Idiom pattern for singletons which require lazy loading for other GOF Singleton is enough.

There are many assumptions made in this blog.. one such is all code written during 1.0 of JDK is good enough to consider as perfect. It is 14 yrs from then. People were not known about GOF patterns.

Josh Bloch was not there with Sun Microsystem. Internet was not famous. 

So  Math class used Static methods.]]></description>
		<content:encoded><![CDATA[<p>I often use Holder Idiom pattern for singletons which require lazy loading for other GOF Singleton is enough.</p>
<p>There are many assumptions made in this blog.. one such is all code written during 1.0 of JDK is good enough to consider as perfect. It is 14 yrs from then. People were not known about GOF patterns.</p>
<p>Josh Bloch was not there with Sun Microsystem. Internet was not famous. </p>
<p>So  Math class used Static methods.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Venkat</title>
		<link>http://webmoli.com/2008/03/27/what-is-the-better-approach-to-implement-singleton-pattern/#comment-181</link>
		<dc:creator><![CDATA[Venkat]]></dc:creator>
		<pubDate>Thu, 27 Nov 2008 03:42:44 +0000</pubDate>
		<guid isPermaLink="false">http://venkatsadasivam.wordpress.com/?p=52#comment-181</guid>
		<description><![CDATA[I take back my word on static method implementation for singleton pattern. Recently I encountered a situation where we need to serialize singleton class (contains static variables/methods); since the variables are static we are not able to serialize the singleton instance.]]></description>
		<content:encoded><![CDATA[<p>I take back my word on static method implementation for singleton pattern. Recently I encountered a situation where we need to serialize singleton class (contains static variables/methods); since the variables are static we are not able to serialize the singleton instance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://webmoli.com/2008/03/27/what-is-the-better-approach-to-implement-singleton-pattern/#comment-180</link>
		<dc:creator><![CDATA[Rob]]></dc:creator>
		<pubDate>Thu, 27 Nov 2008 02:40:34 +0000</pubDate>
		<guid isPermaLink="false">http://venkatsadasivam.wordpress.com/?p=52#comment-180</guid>
		<description><![CDATA[One thing I look to do with &quot;Singletons&quot; is to:
- create an interface as well as the singleton
- the singleton has a field that is of the interface type
- the singleton on initialisation creates an implementation of the interface (you can make this as sophisticated as you like using properties files or Ioc etc)
- the singleton methods proxy through to the underlying implementation of the interface (and yes, I make them all static methods)

You end up with the singleton providing the scope but doing nothing except creating the underlying implementation and being a proxy to the underlying implementation.

I want to minimise the code in the &quot;singleton&quot; as it becomes tightly coupled (not replacable) so whereever possible use the interface and not the singleton. 

You can make the construction of the underlying implementation as simple or as sophisticated as you like (ala pluggable implementation using property files etc to find and construct the implementation).

This may be better described as a &quot;static proxy to a default implementation of an interface&quot; rather than a &quot;singleton&quot;... 

Cheers, Rob.]]></description>
		<content:encoded><![CDATA[<p>One thing I look to do with &#8220;Singletons&#8221; is to:<br />
- create an interface as well as the singleton<br />
- the singleton has a field that is of the interface type<br />
- the singleton on initialisation creates an implementation of the interface (you can make this as sophisticated as you like using properties files or Ioc etc)<br />
- the singleton methods proxy through to the underlying implementation of the interface (and yes, I make them all static methods)</p>
<p>You end up with the singleton providing the scope but doing nothing except creating the underlying implementation and being a proxy to the underlying implementation.</p>
<p>I want to minimise the code in the &#8220;singleton&#8221; as it becomes tightly coupled (not replacable) so whereever possible use the interface and not the singleton. </p>
<p>You can make the construction of the underlying implementation as simple or as sophisticated as you like (ala pluggable implementation using property files etc to find and construct the implementation).</p>
<p>This may be better described as a &#8220;static proxy to a default implementation of an interface&#8221; rather than a &#8220;singleton&#8221;&#8230; </p>
<p>Cheers, Rob.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karthikeyan</title>
		<link>http://webmoli.com/2008/03/27/what-is-the-better-approach-to-implement-singleton-pattern/#comment-63</link>
		<dc:creator><![CDATA[Karthikeyan]]></dc:creator>
		<pubDate>Thu, 29 May 2008 20:06:47 +0000</pubDate>
		<guid isPermaLink="false">http://venkatsadasivam.wordpress.com/?p=52#comment-63</guid>
		<description><![CDATA[Once you refer to static methods callers are tightly coupled to the Singleton class. Suppose we want to have the slightly modified version of Singleton [say limit to 2 such instances of Singleton [or its subclasses]] we will not be able to do so.]]></description>
		<content:encoded><![CDATA[<p>Once you refer to static methods callers are tightly coupled to the Singleton class. Suppose we want to have the slightly modified version of Singleton [say limit to 2 such instances of Singleton [or its subclasses]] we will not be able to do so.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: d descombaz</title>
		<link>http://webmoli.com/2008/03/27/what-is-the-better-approach-to-implement-singleton-pattern/#comment-50</link>
		<dc:creator><![CDATA[d descombaz]]></dc:creator>
		<pubDate>Sun, 30 Mar 2008 09:46:25 +0000</pubDate>
		<guid isPermaLink="false">http://venkatsadasivam.wordpress.com/?p=52#comment-50</guid>
		<description><![CDATA[To add to the first two posts, you wouldn&#039;t be able to inherit, or implement anything either.

I think you are describing the preferred way to make static library in Java. Obviously, it depends upon your needs. A singleton, and a non-instantiable class (outwardly non-instantiable at least) with only static methods and/or properties definitely share characteristics, but they are not the same thing.

Since it doesn&#039;t really create an instance, it increases coupling, and you lose some of the potential benefits of OO design, my feeling is that I wouldn&#039;t generally recommend that someone approaches a singleton this way.]]></description>
		<content:encoded><![CDATA[<p>To add to the first two posts, you wouldn&#8217;t be able to inherit, or implement anything either.</p>
<p>I think you are describing the preferred way to make static library in Java. Obviously, it depends upon your needs. A singleton, and a non-instantiable class (outwardly non-instantiable at least) with only static methods and/or properties definitely share characteristics, but they are not the same thing.</p>
<p>Since it doesn&#8217;t really create an instance, it increases coupling, and you lose some of the potential benefits of OO design, my feeling is that I wouldn&#8217;t generally recommend that someone approaches a singleton this way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: S M Humayun</title>
		<link>http://webmoli.com/2008/03/27/what-is-the-better-approach-to-implement-singleton-pattern/#comment-49</link>
		<dc:creator><![CDATA[S M Humayun]]></dc:creator>
		<pubDate>Fri, 28 Mar 2008 11:06:01 +0000</pubDate>
		<guid isPermaLink="false">http://venkatsadasivam.wordpress.com/?p=52#comment-49</guid>
		<description><![CDATA[IMO static methods approach is not a (better) way to implement  singleton pattern. First, you loose the freedom to pass singleton to others. Secondly, you are tightly coupling the singleton code  with the calling code. Thirdly, static scope is certainly not a good thing to rely on. See &lt;a href=&quot;http://gbracha.blogspot.com/2008/02/cutting-out-static.html&quot; title=&quot;here&quot; rel=&quot;nofollow&quot;&gt; for details.]]></description>
		<content:encoded><![CDATA[<p>IMO static methods approach is not a (better) way to implement  singleton pattern. First, you loose the freedom to pass singleton to others. Secondly, you are tightly coupling the singleton code  with the calling code. Thirdly, static scope is certainly not a good thing to rely on. See <a href="http://gbracha.blogspot.com/2008/02/cutting-out-static.html" title="here" rel="nofollow"> for details.</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Santhosh Kumar</title>
		<link>http://webmoli.com/2008/03/27/what-is-the-better-approach-to-implement-singleton-pattern/#comment-48</link>
		<dc:creator><![CDATA[Santhosh Kumar]]></dc:creator>
		<pubDate>Fri, 28 Mar 2008 06:05:49 +0000</pubDate>
		<guid isPermaLink="false">http://venkatsadasivam.wordpress.com/?p=52#comment-48</guid>
		<description><![CDATA[Wat if i&#039;m supposed to pass my singleton object to a method. Check out this &lt;a href=&quot;http://www.thescripts.com/forum/thread271199.html&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>Wat if i&#8217;m supposed to pass my singleton object to a method. Check out this <a href="http://www.thescripts.com/forum/thread271199.html" rel="nofollow">link</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

