<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://wiki.apidesign.org/skins/common/feed.css?116"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.apidesign.org/index.php?action=history&amp;feed=atom&amp;title=Singleton</id>
		<title>Singleton - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.apidesign.org/index.php?action=history&amp;feed=atom&amp;title=Singleton"/>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;action=history"/>
		<updated>2026-05-01T12:45:06Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.12.0rc1</generator>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=6365&amp;oldid=prev</id>
		<title>JaroslavTulach at 15:02, 17 December 2012</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=6365&amp;oldid=prev"/>
				<updated>2012-12-17T15:02:04Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 15:02, 17 December 2012&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This page is my attempt to explain this [[paradox]]. It may not be complete yet and certainly needs correction. If you have one, feel free to [[Talk:Singleton|share it]]:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This page is my attempt to explain this [[paradox]]. It may not be complete yet and certainly needs correction. If you have one, feel free to [[Talk:Singleton|share it]]:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;comments/&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;I started by reading the Miško's articles references by Witold. Let's thus use them as headers that will guide us though out this polemic.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;I started by reading the Miško's articles references by Witold. Let's thus use them as headers that will guide us though out this polemic.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=4241&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Where Have All the Singletons Gone[http://misko.hevery.com/2008/08/21/where-have-all-the-singletons-gone/] */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=4241&amp;oldid=prev"/>
				<updated>2010-11-08T08:19:50Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Where Have All the Singletons Gone[http://misko.hevery.com/2008/08/21/where-have-all-the-singletons-gone/]&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 08:19, 8 November 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 51:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 51:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;First of all it is easy to ''don't mix object construction and application logic''. Instead of constructing objects, one only calls the [[singleton]]'s getter and gets properly initialized instance of the requested interface. Thus one codes just the application logic, the object construction is handled behind the scene by the [[Lookup|infrastructure]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;First of all it is easy to ''don't mix object construction and application logic''. Instead of constructing objects, one only calls the [[singleton]]'s getter and gets properly initialized instance of the requested interface. Thus one codes just the application logic, the object construction is handled behind the scene by the [[Lookup|infrastructure]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;It is easy to ''rarely call new operation'' - one does not instantiate services, those are offered via various [[API]] singletons. Enough to get them. However, there is an important limitation: In the server terminology one would say that in such system, there is only one factory: the ''application factory''. There are no ''request factories''. The application factory is determined by the classes loaded into the system. All the classes linked together represent one factory (they can have many different [[singleton]]s, but they are all tight together into one configuration set). If I wanted to have different set of singleton values, I would need to load the classes by different &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;classloader &lt;/del&gt;again (see [[co-existence]] for more details).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;It is easy to ''rarely call new operation'' - one does not instantiate services, those are offered via various [[API]] singletons. Enough to get them. However, there is an important limitation: In the server terminology one would say that in such system, there is only one factory: the ''application factory''. There are no ''request factories''. The application factory is determined by the classes loaded into the system. All the classes linked together represent one factory (they can have many different [[singleton]]s, but they are all tight together into one configuration set). If I wanted to have different set of singleton values, I would need to load the classes by different &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[ClassLoader]] &lt;/ins&gt;again (see [[co-existence]] for more details).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The fact that the [[singleton]] approach supports just ''application factory'' shows the benefits of using true [[dependency injection]]. On the other hand the approach is not inherently limiting. For many applications (especially on desktop) it is fine to have just ''application factories''. There is only one ''help system'', one ''dialog presenter'', one VGA card[http://netbeans.org/projects/platform/lists/dev/archive/2010-01/message/406], etc. Thus this limitation does not violate any [[good]] design practices. Using [[singleton]]s in this way is completely fine.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The fact that the [[singleton]] approach supports just ''application factory'' shows the benefits of using true [[dependency injection]]. On the other hand the approach is not inherently limiting. For many applications (especially on desktop) it is fine to have just ''application factories''. There is only one ''help system'', one ''dialog presenter'', one VGA card[http://netbeans.org/projects/platform/lists/dev/archive/2010-01/message/406], etc. Thus this limitation does not violate any [[good]] design practices. Using [[singleton]]s in this way is completely fine.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3437&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Conclusions */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3437&amp;oldid=prev"/>
				<updated>2010-01-26T08:23:41Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Conclusions&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 08:23, 26 January 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Properly used [[Injectable Singleton|singleton]]s are not that bad as one might think after being massaged by [[dependency injection]] campaigns. As soon as we have [[singleton]]s that are inherently initialized and [[injection|injectable]], we get a solution which is on par with solutions provided by [[dependency injection]] (of course just with ''class level'' [[co-existence]], but that is an [[API]] decision, not an implementation flaw).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Properly used [[Injectable Singleton|singleton]]s are not that bad as one might think after being massaged by [[dependency injection]] campaigns. As soon as we have [[singleton]]s that are inherently initialized and [[injection|injectable]], we get a solution which is on par with solutions provided by [[dependency injection]] (of course just with ''class level'' [[co-existence]], but that is an [[API]] decision, not an implementation flaw).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Moreover we managed to increase [[cluelessness]] of our [[API]] users. Whenever one wants to start using an [[API]] with [[Injectable Singleton]]s, one does not need to spend time writing implementation of any interfaces or properly configure system to provide them. Trivial implementations are inherently present in the [[Injectable Singleton]]s by &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;itself&lt;/del&gt;. Of course, if one is not satisfied by them, one is allowed to provide better ones. In some way the [[Injectable Singleton]]s bring the [[Component Injection]] much closer to the motto of [[Convention over Configuration]]: ''If you don't care, use the defaults. If that is not enough for you, specify an alternative''!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Moreover we managed to increase [[cluelessness]] of our [[API]] users. Whenever one wants to start using an [[API]] with [[Injectable Singleton]]s, one does not need to spend time writing implementation of any interfaces or properly configure system to provide them. Trivial implementations are inherently present in the [[Injectable Singleton]]s by &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;their own&lt;/ins&gt;. Of course, if one is not satisfied by them, one is allowed to provide better ones. In some way the [[Injectable Singleton]]s bring the [[Component Injection]] much closer to the motto of [[Convention over Configuration]]: ''If you don't care, use the defaults. If that is not enough for you, specify an alternative''!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;With ten years of active use, seamless [[testability]] (via ''seams''), adherence to [[Convention over Configuration|simplicity of use]] and also with possible bridges with modern [[Dependency Injection]] technologies (see [[LookupAndSpring]]), I would not dare to call [[singleton]]s old trash. Try [[Injectable Singleton]]s, you'll find them friendly!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;With ten years of active use, seamless [[testability]] (via ''seams''), adherence to [[Convention over Configuration|simplicity of use]] and also with possible bridges with modern [[Dependency Injection]] technologies (see [[LookupAndSpring]]), I would not dare to call [[singleton]]s old trash. Try [[Injectable Singleton]]s, you'll find them friendly!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:APIDesignPatterns]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:APIDesignPatterns]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3436&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Top 10 things which make your code hard to test[http://misko.hevery.com/2008/07/30/top-10-things-which-make-your-code-hard-to-test/] */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3436&amp;oldid=prev"/>
				<updated>2010-01-26T08:21:22Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Top 10 things which make your code hard to test[http://misko.hevery.com/2008/07/30/top-10-things-which-make-your-code-hard-to-test/]&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 08:21, 26 January 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Let's look how various Miško's advices about testability materialize when using proper [[singleton]]s.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Let's look how various Miško's advices about testability materialize when using proper [[singleton]]s.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The test shall be a ''small instance of the application''. How small it can be? As small as the tested part that links together. This means that you can have &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;only &lt;/del&gt;only [[API]]s you compiled against on your classpath. Nothing else. And yes, this is satisfied (even to greater extent than any [[Dependency Injection|DI]] solution allows): As the [[API]]s offering [[Injectable Singleton]]s have to provide their default ''dummy'' implementation, you are fine to have just them on the execution classpath. Whatever you compiled against is enough to run reasonably well.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The test shall be a ''small instance of the application''. How small it can be? As small as the tested part that links together. This means that you can have only [[API]]s you compiled against on your classpath. Nothing else. And yes, this is satisfied (even to greater extent than any [[Dependency Injection|DI]] solution allows): As the [[API]]s offering [[Injectable Singleton]]s have to provide their default ''dummy'' implementation, you are fine to have just them on the execution classpath. Whatever you compiled against is enough to run reasonably well.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Of course, the default implementations may not be sufficient for testing all aspects of your application. Often you need to test different behavior than the [[singleton]] provides by itself. Here we need to have a ''seam'', a place to change the standard behavior in a testing handy way. But wait! We have a ''seam''! Each [[Injectable Singleton]] is in fact one!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Of course, the default implementations may not be sufficient for testing all aspects of your application. Often you need to test different behavior than the [[singleton]] provides by itself. Here we need to have a ''seam'', a place to change the standard behavior in a testing handy way. But wait! We have a ''seam''! Each [[Injectable Singleton]] is in fact one!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3435&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Top 10 things which make your code hard to test[http://misko.hevery.com/2008/07/30/top-10-things-which-make-your-code-hard-to-test/] */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3435&amp;oldid=prev"/>
				<updated>2010-01-25T12:01:36Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Top 10 things which make your code hard to test[http://misko.hevery.com/2008/07/30/top-10-things-which-make-your-code-hard-to-test/]&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 12:01, 25 January 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Let's look how various Miško's advices about testability materialize when using proper [[singleton]]s.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Let's look how various Miško's advices about testability materialize when using proper [[singleton]]s.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The test shall be a small instance of the application. How small it can be? As small as the tested part that links together. This means that you can have only only [[API]]s you compiled against on your classpath. Nothing else. And yes, this is satisfied (even to greater extent than any [[Dependency Injection|DI]] solution allows): As the [[API]]s offering [[Injectable Singleton]]s have to provide their default ''dummy'' implementation, you are fine to have just them on the execution classpath. Whatever you compiled against is enough to run reasonably well.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The test shall be a &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;''&lt;/ins&gt;small instance of the application&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;''&lt;/ins&gt;. How small it can be? As small as the tested part that links together. This means that you can have only only [[API]]s you compiled against on your classpath. Nothing else. And yes, this is satisfied (even to greater extent than any [[Dependency Injection|DI]] solution allows): As the [[API]]s offering [[Injectable Singleton]]s have to provide their default ''dummy'' implementation, you are fine to have just them on the execution classpath. Whatever you compiled against is enough to run reasonably well.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Of course, the default implementations may not be sufficient for testing all aspects of your application. Often you need to test different behavior than the [[singleton]] provides by itself. Here we need to have a ''seam'', a place to change the standard behavior in a testing handy way. But wait! We have a ''seam''! Each [[Injectable Singleton]] is in fact one!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Of course, the default implementations may not be sufficient for testing all aspects of your application. Often you need to test different behavior than the [[singleton]] provides by itself. Here we need to have a ''seam'', a place to change the standard behavior in a testing handy way. But wait! We have a ''seam''! Each [[Injectable Singleton]] is in fact one!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3431&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Conclusions */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3431&amp;oldid=prev"/>
				<updated>2010-01-25T08:58:48Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Conclusions&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 08:58, 25 January 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Properly used [[Injectable Singleton|singleton]]s are not that bad as one might think after being massaged by [[dependency injection]] campaigns. As soon as we have [[singleton]]s that are inherently initialized and [[injection|injectable]], we get a solution which is on par with solutions provided by [[dependency injection]] (of course just with ''class level'' [[co-existence]], but that is an [[API]] decision, not an implementation flaw).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Properly used [[Injectable Singleton|singleton]]s are not that bad as one might think after being massaged by [[dependency injection]] campaigns. As soon as we have [[singleton]]s that are inherently initialized and [[injection|injectable]], we get a solution which is on par with solutions provided by [[dependency injection]] (of course just with ''class level'' [[co-existence]], but that is an [[API]] decision, not an implementation flaw).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Moreover we managed to increase [[cluelessness]] of our [[API]] users. Whenever one wants to start using an [[API]] with [[Injectable Singleton]]s, one does not need to spend time &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;to write &lt;/del&gt;implementation of &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;such &lt;/del&gt;interfaces or properly configure system to provide &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;one&lt;/del&gt;. Trivial implementations are inherently present in the [[Injectable Singleton]]s by itself. Of course, if one is not satisfied by them, one is allowed to provide better ones. In some way the [[Injectable Singleton]]s bring the [[Component Injection]] much closer to the motto of [[Convention over Configuration]]: ''If you don't care, use the defaults. If that is not enough for you, specify an alternative''!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Moreover we managed to increase [[cluelessness]] of our [[API]] users. Whenever one wants to start using an [[API]] with [[Injectable Singleton]]s, one does not need to spend time &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;writing &lt;/ins&gt;implementation of &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;any &lt;/ins&gt;interfaces or properly configure system to provide &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;them&lt;/ins&gt;. Trivial implementations are inherently present in the [[Injectable Singleton]]s by itself. Of course, if one is not satisfied by them, one is allowed to provide better ones. In some way the [[Injectable Singleton]]s bring the [[Component Injection]] much closer to the motto of [[Convention over Configuration]]: ''If you don't care, use the defaults. If that is not enough for you, specify an alternative''!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;With ten years of active use, seamless [[testability]] (via ''seams''), adherence to [[Convention over Configuration|simplicity of use]] and also with possible bridges with modern [[Dependency Injection]] technologies (see [[LookupAndSpring]]), I would not dare to call [[singleton]]s old trash. Try [[Injectable Singleton]]s, you'll find them friendly!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;With ten years of active use, seamless [[testability]] (via ''seams''), adherence to [[Convention over Configuration|simplicity of use]] and also with possible bridges with modern [[Dependency Injection]] technologies (see [[LookupAndSpring]]), I would not dare to call [[singleton]]s old trash. Try [[Injectable Singleton]]s, you'll find them friendly!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:APIDesignPatterns]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:APIDesignPatterns]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3430&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Conclusions */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3430&amp;oldid=prev"/>
				<updated>2010-01-25T08:58:04Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Conclusions&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 08:58, 25 January 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Properly used [[Injectable Singleton|singleton]]s are not that bad as one might think after being massaged by [[dependency injection]] campaigns. As soon as we have [[singleton]]s that are inherently initialized and [[injection|injectable]], we get a solution which is on par with solutions provided by [[dependency injection]] (of course just with ''class level'' [[co-existence]], but that is an [[API]] decision, not an implementation flaw).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Properly used [[Injectable Singleton|singleton]]s are not that bad as one might think after being massaged by [[dependency injection]] campaigns. As soon as we have [[singleton]]s that are inherently initialized and [[injection|injectable]], we get a solution which is on par with solutions provided by [[dependency injection]] (of course just with ''class level'' [[co-existence]], but that is an [[API]] decision, not an implementation flaw).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Moreover we managed to increase [[cluelessness]] of our [[API]] users. Whenever one wants to start using an [[API]] with [[Injectable Singleton]]s, one does not need to spend time to write implementation of such interfaces or properly configure system to provide one. Trivial implementations are inherently present in the [[Injectable Singleton]]s by itself. Of course, if one is not &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;satisfy with &lt;/del&gt;them, one is allowed to provide better ones. In some way the [[Injectable Singleton]]s bring the [[Component Injection]] much closer to the motto of [[Convention over Configuration]]: ''If you don't care, use the defaults. If that is not enough for you, specify an alternative''!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Moreover we managed to increase [[cluelessness]] of our [[API]] users. Whenever one wants to start using an [[API]] with [[Injectable Singleton]]s, one does not need to spend time to write implementation of such interfaces or properly configure system to provide one. Trivial implementations are inherently present in the [[Injectable Singleton]]s by itself. Of course, if one is not &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;satisfied by &lt;/ins&gt;them, one is allowed to provide better ones. In some way the [[Injectable Singleton]]s bring the [[Component Injection]] much closer to the motto of [[Convention over Configuration]]: ''If you don't care, use the defaults. If that is not enough for you, specify an alternative''!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;With ten years of active use, seamless [[testability]] (via ''seams''), adherence to [[Convention over Configuration|simplicity of use]] and also with possible bridges with modern [[Dependency Injection]] technologies (see [[LookupAndSpring]]), I would not dare to call [[singleton]]s old trash. Try [[Injectable Singleton]]s, you'll find them friendly!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;With ten years of active use, seamless [[testability]] (via ''seams''), adherence to [[Convention over Configuration|simplicity of use]] and also with possible bridges with modern [[Dependency Injection]] technologies (see [[LookupAndSpring]]), I would not dare to call [[singleton]]s old trash. Try [[Injectable Singleton]]s, you'll find them friendly!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:APIDesignPatterns]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:APIDesignPatterns]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3429&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Conclusions */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3429&amp;oldid=prev"/>
				<updated>2010-01-25T08:57:25Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Conclusions&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 08:57, 25 January 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Properly used [[Injectable Singleton|singleton]]s are not that bad as one might think after being massaged by [[dependency injection]] campaigns. As soon as we have [[singleton]]s that are inherently initialized and [[injection|injectable]], we get a solution which is on par with solutions provided by [[dependency injection]] (of course just with ''class level'' [[co-existence]], but that is an [[API]] decision, not an implementation flaw).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Properly used [[Injectable Singleton|singleton]]s are not that bad as one might think after being massaged by [[dependency injection]] campaigns. As soon as we have [[singleton]]s that are inherently initialized and [[injection|injectable]], we get a solution which is on par with solutions provided by [[dependency injection]] (of course just with ''class level'' [[co-existence]], but that is an [[API]] decision, not an implementation flaw).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Moreover we managed to &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;increased our users &lt;/del&gt;[[cluelessness]]. Whenever one wants to start using an [[API]] with [[Injectable Singleton]]s, one does not need to spend time to write implementation of such interfaces or properly configure system to provide one. Trivial implementations are inherently present in the [[Injectable Singleton]]s by itself. Of course, if one is not satisfy with them, one is allowed to provide better ones. In some way the [[Injectable Singleton]]s bring the [[Component Injection]] much closer to the motto of [[Convention over Configuration]]: ''If you don't care, use the defaults. If that is not enough for you, specify an alternative''!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Moreover we managed to &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;increase &lt;/ins&gt;[[cluelessness]] &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;of our [[API]] users&lt;/ins&gt;. Whenever one wants to start using an [[API]] with [[Injectable Singleton]]s, one does not need to spend time to write implementation of such interfaces or properly configure system to provide one. Trivial implementations are inherently present in the [[Injectable Singleton]]s by itself. Of course, if one is not satisfy with them, one is allowed to provide better ones. In some way the [[Injectable Singleton]]s bring the [[Component Injection]] much closer to the motto of [[Convention over Configuration]]: ''If you don't care, use the defaults. If that is not enough for you, specify an alternative''!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;With ten years of active use, seamless [[testability]] (via ''seams''), adherence to [[Convention over Configuration|simplicity of use]] and also with possible bridges with modern [[Dependency Injection]] technologies (see [[LookupAndSpring]]), I would not dare to call [[singleton]]s old trash. Try [[Injectable Singleton]]s, you'll find them friendly!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;With ten years of active use, seamless [[testability]] (via ''seams''), adherence to [[Convention over Configuration|simplicity of use]] and also with possible bridges with modern [[Dependency Injection]] technologies (see [[LookupAndSpring]]), I would not dare to call [[singleton]]s old trash. Try [[Injectable Singleton]]s, you'll find them friendly!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:APIDesignPatterns]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:APIDesignPatterns]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3428&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Root Cause of Singletons[http://misko.hevery.com/2008/08/25/root-cause-of-singletons/] */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3428&amp;oldid=prev"/>
				<updated>2010-01-25T08:54:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Root Cause of Singletons[http://misko.hevery.com/2008/08/25/root-cause-of-singletons/]&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 08:54, 25 January 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 59:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 59:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In this piece Miško admits that using ''immutable [[singleton]]'' is OK. Good progress since the first write up. Now the question is what is meant by ''immutable''? The content of help system window is certainly not immutable and still it is fine to provide access to its [[API]] via a [[singleton]] under the assumption that it is ready to perform its operation (display some help page). Thus I am going to assume that ''immutable'' [[singleton]] means ''not configurable'' or without a need to call some init code to ''configure'' it. Let's see the necessary attributes of [[injectable singleton]]s to eliminate any need for ''configuration''.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In this piece Miško admits that using ''immutable [[singleton]]'' is OK. Good progress since the first write up. Now the question is what is meant by ''immutable''? The content of help system window is certainly not immutable and still it is fine to provide access to its [[API]] via a [[singleton]] under the assumption that it is ready to perform its operation (display some help page). Thus I am going to assume that ''immutable'' [[singleton]] means ''not configurable'' or without a need to call some init code to ''configure'' it. Let's see the necessary attributes of [[injectable singleton]]s to eliminate any need for ''configuration''.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;First of all the [[API]] itself needs to provide some implementation of the [[singleton]]. This implementation may be trivial, yet have to be functional. For example a [[singleton]] that is supposed to show dialogs to user and ask questions may always print the question to System.err and choose ''cancel''. This way we eliminate the worry that [[singleton]]s may lie about their dependencies - they don't have any. As soon as the system successfully links, all [[singleton]]s are ready to work &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;fine&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;First of all the [[API]] itself needs to provide some implementation of the [[singleton]]. This implementation may be trivial, yet have to be functional. For example a [[singleton]] that is supposed to show dialogs to user and ask questions may always print the question to System.err and choose ''cancel''. This way we eliminate the worry that [[singleton]]s may lie about their dependencies - they don't have any. As soon as the system successfully links, all [[singleton]]s are ready to work.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Second, the implementations of the [[singleton]]s need to be [[injection|injectable]] - e.g. it is possible to [[injection|inject]] better implementation into the [[singleton]]. Such [[injection]] can happen only before the [[singleton]] is used and (preferably) without invoking any initialization code (see [[Injectable Singleton#Configuration|injectable configuration]] for details). This serves two important goals. Production systems are configured to provide ''clever'' (read not ''dummy'') implementations of the [[singleton]]s without affecting code using these [[singleton]]s. Also, it is possible to easily mock each [[singleton]] in a unit test fully addressing needs of [[Injectable Singleton#Testability|testability]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Second, the implementations of the [[singleton]]s need to be [[injection|injectable]] - e.g. it is possible to [[injection|inject]] better implementation into the [[singleton]]. Such [[injection]] can happen only before the [[singleton]] is used and (preferably) without invoking any initialization code (see [[Injectable Singleton#Configuration|injectable configuration]] for details). This serves two important goals. Production systems are configured to provide ''clever'' (read not ''dummy'') implementations of the [[singleton]]s without affecting code using these [[singleton]]s. Also, it is possible to easily mock each [[singleton]] in a unit test fully addressing needs of [[Injectable Singleton#Testability|testability]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3427&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Root Cause of Singletons[http://misko.hevery.com/2008/08/25/root-cause-of-singletons/] */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=Singleton&amp;diff=3427&amp;oldid=prev"/>
				<updated>2010-01-25T08:53:44Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Root Cause of Singletons[http://misko.hevery.com/2008/08/25/root-cause-of-singletons/]&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 08:53, 25 January 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 59:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 59:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In this piece Miško admits that using ''immutable [[singleton]]'' is OK. Good progress since the first write up. Now the question is what is meant by ''immutable''? The content of help system window is certainly not immutable and still it is fine to provide access to its [[API]] via a [[singleton]] under the assumption that it is ready to perform its operation (display some help page). Thus I am going to assume that ''immutable'' [[singleton]] means ''not configurable'' or without a need to call some init code to ''configure'' it. Let's see the necessary attributes of [[injectable singleton]]s to eliminate any need for ''configuration''.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In this piece Miško admits that using ''immutable [[singleton]]'' is OK. Good progress since the first write up. Now the question is what is meant by ''immutable''? The content of help system window is certainly not immutable and still it is fine to provide access to its [[API]] via a [[singleton]] under the assumption that it is ready to perform its operation (display some help page). Thus I am going to assume that ''immutable'' [[singleton]] means ''not configurable'' or without a need to call some init code to ''configure'' it. Let's see the necessary attributes of [[injectable singleton]]s to eliminate any need for ''configuration''.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;First of all the [[API]] itself needs to provide some implementation of the [[singleton]]. This implementation may be trivial, yet have to be functional. For example a [[singleton]] that is supposed to show dialogs to user and ask questions may always print the question to System.err and choose ''cancel''. This way we eliminate the worry that [[singleton]]s may lie about their dependencies - they don't &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;they &lt;/del&gt;have any. As soon as the system successfully links, all [[singleton]]s are ready to work fine.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;First of all the [[API]] itself needs to provide some implementation of the [[singleton]]. This implementation may be trivial, yet have to be functional. For example a [[singleton]] that is supposed to show dialogs to user and ask questions may always print the question to System.err and choose ''cancel''. This way we eliminate the worry that [[singleton]]s may lie about their dependencies - they don't have any. As soon as the system successfully links, all [[singleton]]s are ready to work fine.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Second, the implementations of the [[singleton]]s need to be [[injection|injectable]] - e.g. it is possible to [[injection|inject]] better implementation into the [[singleton]]. Such [[injection]] can happen only before the [[singleton]] is used and (preferably) without invoking any initialization code (see [[Injectable Singleton#Configuration|injectable configuration]] for details). This serves two important goals. Production systems are configured to provide ''clever'' (read not ''dummy'') implementations of the [[singleton]]s without affecting code using these [[singleton]]s. Also, it is possible to easily mock each [[singleton]] in a unit test fully addressing needs of [[Injectable Singleton#Testability|testability]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Second, the implementations of the [[singleton]]s need to be [[injection|injectable]] - e.g. it is possible to [[injection|inject]] better implementation into the [[singleton]]. Such [[injection]] can happen only before the [[singleton]] is used and (preferably) without invoking any initialization code (see [[Injectable Singleton#Configuration|injectable configuration]] for details). This serves two important goals. Production systems are configured to provide ''clever'' (read not ''dummy'') implementations of the [[singleton]]s without affecting code using these [[singleton]]s. Also, it is possible to easily mock each [[singleton]] in a unit test fully addressing needs of [[Injectable Singleton#Testability|testability]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	</feed>