<?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:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
	>
<channel>
	<title>Comments on: Saint Singleton: Have We Martyred a Design Pattern Unfairly?</title>
	<atom:link href="http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/</link>
	<description>OOP Techniques for Flash and Flex Developers</description>
	<lastBuildDate>Mon, 26 Jul 2010 13:40:37 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: mike</title>
		<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/comment-page-1/#comment-2976</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Tue, 15 Sep 2009 14:37:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=1424#comment-2976</guid>
		<description>http://www.thelasthouseontheleft.com/


Here&#039;s one. Its pretty simple and straightforward as well as being a fairly typical sequence.

Loader &gt; Intro &gt; Main &gt; Loader &gt; Sections

I think like I said one of the things I&#039;m curious about is Global control and monitoring of actions that are taking place within sections... oh a Video is being played stop music, a link was clicked stop music and video. The other thing is passing of data between unrelated things. Main loads a master xml... knows to load a video for next section... plays next section... next section grabs xml from Main.

I guess what I&#039;ve been starting to see is that for components with in the site I can pick out a design pattern like for the video component, or wallpaper switcher, sound controller, photo swapper/enlarger. But then the piece I can&#039;t see is how to then link all these together and be able to monitor them all in the Main/Client cleanly without sending arbitrary commands back and forth and always checking thing&#039;s with if statements all over the place.</description>
		<content:encoded><![CDATA[<p><a href="http://www.thelasthouseontheleft.com/" rel="nofollow">http://www.thelasthouseontheleft.com/</a></p>
<p>Here&#8217;s one. Its pretty simple and straightforward as well as being a fairly typical sequence.</p>
<p>Loader &gt; Intro &gt; Main &gt; Loader &gt; Sections</p>
<p>I think like I said one of the things I&#8217;m curious about is Global control and monitoring of actions that are taking place within sections&#8230; oh a Video is being played stop music, a link was clicked stop music and video. The other thing is passing of data between unrelated things. Main loads a master xml&#8230; knows to load a video for next section&#8230; plays next section&#8230; next section grabs xml from Main.</p>
<p>I guess what I&#8217;ve been starting to see is that for components with in the site I can pick out a design pattern like for the video component, or wallpaper switcher, sound controller, photo swapper/enlarger. But then the piece I can&#8217;t see is how to then link all these together and be able to monitor them all in the Main/Client cleanly without sending arbitrary commands back and forth and always checking thing&#8217;s with if statements all over the place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark A.</title>
		<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/comment-page-1/#comment-2973</link>
		<dc:creator>Mark A.</dc:creator>
		<pubDate>Tue, 15 Sep 2009 11:09:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=1424#comment-2973</guid>
		<description>nice offer. looking forward to the result :)</description>
		<content:encoded><![CDATA[<p>nice offer. looking forward to the result :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William B. Sanders</title>
		<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/comment-page-1/#comment-2972</link>
		<dc:creator>William B. Sanders</dc:creator>
		<pubDate>Tue, 15 Sep 2009 09:54:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=1424#comment-2972</guid>
		<description>Hi Mike,

One of the problems I had to &lt;em&gt;unlearn&lt;/em&gt; was tightening up my code--I had to loosen it up considerably. Also, I found it helpful to drop the name Main and use Client instead. (I did this simply because GoF uses &lt;strong&gt;Client&lt;/strong&gt; as the name for the class that made requests from the classes in the design pattern.)

For the time being, forget there&#039;s anything like a global variable—in fact, let&#039;s pretend they don&#039;t exist. Also, for the sake of argument, we&#039;ll also pretend that GoF never introduced the Singleton.

So here we are with the key question, &lt;em&gt;What varies?&lt;/em&gt; You want to turn music on and off; so, you can see that &lt;em&gt;state&lt;/em&gt; varies. Further, you have a &lt;em&gt;number of objects that depend on another object along with how the dependent objects stay up to date&lt;/em&gt; with all of the different videos and images. Another way of putting that is you have a situation where the State and Observer designs can be of help. With those two patterns, why not make a MVC? (Or a PureMVC?)

For a long time now, I&#039;ve wanted to create a relatively simple MVC for the Lunch Bucket series (design patterns you can take to work) and your kind of project sounds to be a perfect candidate—albeit a scaled down and simplified version. The goal would be to coordinate video play, photos, download and sounds. (This &lt;em&gt;might&lt;/em&gt; suggest that we&#039;re dealing with &lt;em&gt;families of product objects that vary&lt;/em&gt;, and hence the Abstract Factory, but with the MVC there&#039;s the ability to include more than a single design pattern.)

The goal is to create a design that would be easy to update and  changes don&#039;t domino fall throughout your project. Does that sound about right? Send a URL that shows the end results, and I&#039;ll put a &lt;em&gt;just the basics&lt;/em&gt; MVC together to do the same thing. It will call on the following:

1. Graphics (in SWF and graphic formats, I&#039;m assuming)
2. Video (progressive download or FMS?)
3. Sound (MP3 files)
4. Flash animations (in SWF files)

Is that about right? I don&#039;t want to know anything about your code or your current setup—just what you expect for an outcome and for maintenance.

Kindest regards,
Bill</description>
		<content:encoded><![CDATA[<p>Hi Mike,</p>
<p>One of the problems I had to <em>unlearn</em> was tightening up my code&#8211;I had to loosen it up considerably. Also, I found it helpful to drop the name Main and use Client instead. (I did this simply because GoF uses <strong>Client</strong> as the name for the class that made requests from the classes in the design pattern.)</p>
<p>For the time being, forget there&#8217;s anything like a global variable—in fact, let&#8217;s pretend they don&#8217;t exist. Also, for the sake of argument, we&#8217;ll also pretend that GoF never introduced the Singleton.</p>
<p>So here we are with the key question, <em>What varies?</em> You want to turn music on and off; so, you can see that <em>state</em> varies. Further, you have a <em>number of objects that depend on another object along with how the dependent objects stay up to date</em> with all of the different videos and images. Another way of putting that is you have a situation where the State and Observer designs can be of help. With those two patterns, why not make a MVC? (Or a PureMVC?)</p>
<p>For a long time now, I&#8217;ve wanted to create a relatively simple MVC for the Lunch Bucket series (design patterns you can take to work) and your kind of project sounds to be a perfect candidate—albeit a scaled down and simplified version. The goal would be to coordinate video play, photos, download and sounds. (This <em>might</em> suggest that we&#8217;re dealing with <em>families of product objects that vary</em>, and hence the Abstract Factory, but with the MVC there&#8217;s the ability to include more than a single design pattern.)</p>
<p>The goal is to create a design that would be easy to update and  changes don&#8217;t domino fall throughout your project. Does that sound about right? Send a URL that shows the end results, and I&#8217;ll put a <em>just the basics</em> MVC together to do the same thing. It will call on the following:</p>
<p>1. Graphics (in SWF and graphic formats, I&#8217;m assuming)<br />
2. Video (progressive download or FMS?)<br />
3. Sound (MP3 files)<br />
4. Flash animations (in SWF files)</p>
<p>Is that about right? I don&#8217;t want to know anything about your code or your current setup—just what you expect for an outcome and for maintenance.</p>
<p>Kindest regards,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/comment-page-1/#comment-2970</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Tue, 15 Sep 2009 03:23:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=1424#comment-2970</guid>
		<description>While thats an amazingly generous offer I would find it almost impossible to choose which project I and everyone else could learn from the most. Especially when after each project I go and try to &#039;better&#039; something I found to be an annoyance in a previous project.

I guess my most common task would be a SoundController (which I could then relate to several other tasks). Here is a typical set up.

Main.SWF
----------
Contains SoundController
Loads Section SWF&#039;s
Plays Main MP3

Section.SWF&#039;s
----------
Loads Video or Photos or Downloads ect...
Triggers several Sound FX and perhaps a new main MP3.

I need all sounds in my website to be able to be turned off all at once from within my Main.SWF, triggered from several different Section.SWF files, and I also need them according to a variable be retained in memory so I don&#039;t have to burden the server over and over for a sound file that is used more then once.

Without wanting to pass references to a newly loaded SWF immediately upon loading it to be able to use the same SoundController. I know I could also use Getter/Setter but then I also need an easily obtainable reference to the Main.SWF which houses my SoundController. Would it not need to be a Singleton, otherwise it would not be able to be turned off Globally from 1 spot and also not use the same &#039;memory&#039; table.</description>
		<content:encoded><![CDATA[<p>While thats an amazingly generous offer I would find it almost impossible to choose which project I and everyone else could learn from the most. Especially when after each project I go and try to &#8216;better&#8217; something I found to be an annoyance in a previous project.</p>
<p>I guess my most common task would be a SoundController (which I could then relate to several other tasks). Here is a typical set up.</p>
<p>Main.SWF<br />
&#8212;&#8212;&#8212;-<br />
Contains SoundController<br />
Loads Section SWF&#8217;s<br />
Plays Main MP3</p>
<p>Section.SWF&#8217;s<br />
&#8212;&#8212;&#8212;-<br />
Loads Video or Photos or Downloads ect&#8230;<br />
Triggers several Sound FX and perhaps a new main MP3.</p>
<p>I need all sounds in my website to be able to be turned off all at once from within my Main.SWF, triggered from several different Section.SWF files, and I also need them according to a variable be retained in memory so I don&#8217;t have to burden the server over and over for a sound file that is used more then once.</p>
<p>Without wanting to pass references to a newly loaded SWF immediately upon loading it to be able to use the same SoundController. I know I could also use Getter/Setter but then I also need an easily obtainable reference to the Main.SWF which houses my SoundController. Would it not need to be a Singleton, otherwise it would not be able to be turned off Globally from 1 spot and also not use the same &#8216;memory&#8217; table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William B. Sanders</title>
		<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/comment-page-1/#comment-2966</link>
		<dc:creator>William B. Sanders</dc:creator>
		<pubDate>Mon, 14 Sep 2009 18:44:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=1424#comment-2966</guid>
		<description>Hi Mike,

Without knowing what your projects do and how they&#039;re set up, it&#039;s impossible to say where a Singleton may come up and bite you. I just don&#039;t like the possibility of an IED in my code. Further, while you know of no other way to do what you&#039;re doing, we both know that some bright light will come along with a better way that neither of us thought of. It may be with a design pattern or not, but most likely it will be an OOP solution.

The issue has &lt;em&gt;never been&lt;/em&gt; that Singletons don&#039;t work. They do. The problems are more subtle and as you note, you don&#039;t see the problem with global variables either. They have creepy characteristics that will get you sooner or later, and I avoid them because of that. However, you can do things with globals that you cannot do otherwise. The problem is that if a global can achieve a task that nothing else can, you&#039;ve probably picked an non-OOP solution.

I think a lot of us end up using non-DP solutions because it just takes too long to work out a dp solution, or you have a solution that has worked well without any problems and the time and effort to change are too great.

As we muddle our way through all of this, we improve by nano-degrees, and all of us want better code. That&#039;s why I brought up the limitations and problems with using Singletons.

Ironically, at next month&#039;s OOPSLA meetings I&#039;ve been asked to deliver a presentation on where a non-OOP solutions works while an OOP solution doesn&#039;t! (The author of the paper has to be away judging a Computer Science competition.)

Here&#039;s an idea. Let&#039;s take some project you do and find a DP solution for it. It can be an old one (and something small!) so you won&#039;t get into contract trouble. Then we can explore something practical and possibly come up with the kind of solution you&#039;re seeking.

Kindest regards,
Bill</description>
		<content:encoded><![CDATA[<p>Hi Mike,</p>
<p>Without knowing what your projects do and how they&#8217;re set up, it&#8217;s impossible to say where a Singleton may come up and bite you. I just don&#8217;t like the possibility of an IED in my code. Further, while you know of no other way to do what you&#8217;re doing, we both know that some bright light will come along with a better way that neither of us thought of. It may be with a design pattern or not, but most likely it will be an OOP solution.</p>
<p>The issue has <em>never been</em> that Singletons don&#8217;t work. They do. The problems are more subtle and as you note, you don&#8217;t see the problem with global variables either. They have creepy characteristics that will get you sooner or later, and I avoid them because of that. However, you can do things with globals that you cannot do otherwise. The problem is that if a global can achieve a task that nothing else can, you&#8217;ve probably picked an non-OOP solution.</p>
<p>I think a lot of us end up using non-DP solutions because it just takes too long to work out a dp solution, or you have a solution that has worked well without any problems and the time and effort to change are too great.</p>
<p>As we muddle our way through all of this, we improve by nano-degrees, and all of us want better code. That&#8217;s why I brought up the limitations and problems with using Singletons.</p>
<p>Ironically, at next month&#8217;s OOPSLA meetings I&#8217;ve been asked to deliver a presentation on where a non-OOP solutions works while an OOP solution doesn&#8217;t! (The author of the paper has to be away judging a Computer Science competition.)</p>
<p>Here&#8217;s an idea. Let&#8217;s take some project you do and find a DP solution for it. It can be an old one (and something small!) so you won&#8217;t get into contract trouble. Then we can explore something practical and possibly come up with the kind of solution you&#8217;re seeking.</p>
<p>Kindest regards,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/comment-page-1/#comment-2963</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Mon, 14 Sep 2009 17:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=1424#comment-2963</guid>
		<description>So... I&#039;m fairly new to Design Patterns (sorta). I am not new to AS3 though. 

Now maybe its because of the type of things I am asked to develop but I have to say I use a Global Singleton at the beginning of all my projects and bring it into most of my files. The stuff I develop is all highly graphical and elaborately designed websites for Movie Studios... Paramount, Fox, Universal ect...

As much as I&#039;d like to follow nice clean patterns all the time I just find it impossible sometimes. Here&#039;s what I keep track of with my Global:

XML Files (text, release dates, videos, photos, ect..)
Initial SWF&#039;s (Main, Home)
-- the above is contained in a BulkLoader --
Reference to BulkLoader
Reference to Main.swf

Then throughout my Flash project I simply call up the xml file needed through my Global.vars.BulkLoader reference. I also keep my SoundController in my Main.swf so alot of times I talk back and forth with the Main.swf to trigger sounds, mute all sounds, turn them on.

I just don&#039;t see any real other way around certain things then keeping them Global across my project. I try to use my Main.swf as my Globally accesible control panel and keep one reference to my Main.swf in my Global Singleton so I can talk to it easily anywhere I need to. Which like I said could be SoundControllers, TextureLoaders, Global Site Pausers, Video Controllers that also react to SoundControllers. 

In my case I just don&#039;t think there&#039;s a better way to control multiple swf&#039;s and multiple things going on at once without the use of at least my one Global Singleton.</description>
		<content:encoded><![CDATA[<p>So&#8230; I&#8217;m fairly new to Design Patterns (sorta). I am not new to AS3 though. </p>
<p>Now maybe its because of the type of things I am asked to develop but I have to say I use a Global Singleton at the beginning of all my projects and bring it into most of my files. The stuff I develop is all highly graphical and elaborately designed websites for Movie Studios&#8230; Paramount, Fox, Universal ect&#8230;</p>
<p>As much as I&#8217;d like to follow nice clean patterns all the time I just find it impossible sometimes. Here&#8217;s what I keep track of with my Global:</p>
<p>XML Files (text, release dates, videos, photos, ect..)<br />
Initial SWF&#8217;s (Main, Home)<br />
&#8211; the above is contained in a BulkLoader &#8211;<br />
Reference to BulkLoader<br />
Reference to Main.swf</p>
<p>Then throughout my Flash project I simply call up the xml file needed through my Global.vars.BulkLoader reference. I also keep my SoundController in my Main.swf so alot of times I talk back and forth with the Main.swf to trigger sounds, mute all sounds, turn them on.</p>
<p>I just don&#8217;t see any real other way around certain things then keeping them Global across my project. I try to use my Main.swf as my Globally accesible control panel and keep one reference to my Main.swf in my Global Singleton so I can talk to it easily anywhere I need to. Which like I said could be SoundControllers, TextureLoaders, Global Site Pausers, Video Controllers that also react to SoundControllers. </p>
<p>In my case I just don&#8217;t think there&#8217;s a better way to control multiple swf&#8217;s and multiple things going on at once without the use of at least my one Global Singleton.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William B. Sanders</title>
		<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/comment-page-1/#comment-2923</link>
		<dc:creator>William B. Sanders</dc:creator>
		<pubDate>Fri, 11 Sep 2009 01:32:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=1424#comment-2923</guid>
		<description>Hi Hugo,

First off, it&#039;s dangerous to cite wikipedia--take a look at their &quot;explanation&quot; of a Private Class. Second, I didn&#039;t mean to sound insulting in differentiating a singleton from a Singleton for you—some people really don&#039;t know.

In all of the examples you cite, you talk about the Singleton &lt;em&gt;as a possible&lt;/em&gt; inclusion in those design patterns, but why? Because there&#039;s only a single Facade class in a Facade design pattern does not make it a Singleton class. In fact, it behaves very differently from a Singleton. A Facade handles variation as an interface to a subsystem, while a Singleton handles variation as the sole instance of a class.

If you added a Singleton to an Abstract Factory, it&#039;s like putting a wart on the face of a beauty queen. Why would anyone do it? As for State objects being Singletons, I just don&#039;t agree. It&#039;s hard to imagine something as dynamic as a State implementation being a Singleton. In fact it gives me the creeps....

In loggers I can see the purpose of a Singleton. But seeing a purpose does not mean it&#039;s a good idea to add a possible global variable to your mix.

However, this post (&lt;em&gt;Saint Singleton: Have We Martyred a Design Pattern Unfairly?&lt;/em&gt;) was meant to encourage discussion, and  with so many bright people on our blog, I should have expected more than a shrug from our readers.

So get involved in our Golden Lunch Bucket Contest #4 and enter the Golden Lunch Bucket World Cup!

Thanks for hanging in there.

Kindest regards,
Bill</description>
		<content:encoded><![CDATA[<p>Hi Hugo,</p>
<p>First off, it&#8217;s dangerous to cite wikipedia&#8211;take a look at their &#8220;explanation&#8221; of a Private Class. Second, I didn&#8217;t mean to sound insulting in differentiating a singleton from a Singleton for you—some people really don&#8217;t know.</p>
<p>In all of the examples you cite, you talk about the Singleton <em>as a possible</em> inclusion in those design patterns, but why? Because there&#8217;s only a single Facade class in a Facade design pattern does not make it a Singleton class. In fact, it behaves very differently from a Singleton. A Facade handles variation as an interface to a subsystem, while a Singleton handles variation as the sole instance of a class.</p>
<p>If you added a Singleton to an Abstract Factory, it&#8217;s like putting a wart on the face of a beauty queen. Why would anyone do it? As for State objects being Singletons, I just don&#8217;t agree. It&#8217;s hard to imagine something as dynamic as a State implementation being a Singleton. In fact it gives me the creeps&#8230;.</p>
<p>In loggers I can see the purpose of a Singleton. But seeing a purpose does not mean it&#8217;s a good idea to add a possible global variable to your mix.</p>
<p>However, this post (<em>Saint Singleton: Have We Martyred a Design Pattern Unfairly?</em>) was meant to encourage discussion, and  with so many bright people on our blog, I should have expected more than a shrug from our readers.</p>
<p>So get involved in our Golden Lunch Bucket Contest #4 and enter the Golden Lunch Bucket World Cup!</p>
<p>Thanks for hanging in there.</p>
<p>Kindest regards,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hugo</title>
		<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/comment-page-1/#comment-2920</link>
		<dc:creator>Hugo</dc:creator>
		<pubDate>Thu, 10 Sep 2009 22:11:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=1424#comment-2920</guid>
		<description>Hi Bill, i know that singleton is the class and the pattern is Singleton but ok .. i didn-t explain myself correctly.
by the way 
&quot;
* The Abstract Factory, Builder, and Prototype patterns can use Singletons in their implementation.
    * Facade objects are often Singletons because only one Facade object is required.
    * State objects are often Singletons.
    * Singletons are often preferred to global variables because:
          o They don&#039;t pollute the global namespace (or, in languages with namespaces, their containing namespace) with unnecessary variables.[7]
          o They permit lazy allocation and initialization, where global variables in many languages will always consume resources.
&quot;
this according to wikipedia.
http://en.wikipedia.org/wiki/Singleton_pattern
but as a personal experience using the Singleton Pattern if i use it at an higher level in my app it does permit loose coupling the problem with Actionscript like it was said before is that Actionscript doesn&#039;t really have a correct way to implement it. There are hacks to it,Grant Skinner and others have largely blogged about it.

The thing about the Singleton Pattern according to standards is that is makes the Application not to follow a principal like a class having a single responsability.

Should a principle be a law ? does it mean i have to have just one responsability in a class

the Singleton Pattern definition says:
&quot;Singleton is a class which permits itself to be instantiated only once. It…

        * has a private or protected constructor with no parameters.
        * has a single, global means of access via a static method.
        * cannot be subclassed nor instantiated with the new operator.
        * uses lazy instantiation. 
&quot;
&quot;
Singleton can be used—in fact, is required—in many situations, for example:

        * caches
        * device drivers
        * dialog boxes
        * loggers
        * thread pools 

&quot;

so is it really that bad to use a Singleton ? 

furthermore i found an excellent entrie on the subject and yes it bashes the GOF Singleton Pattern but it also states that there are some places where the use of the Singleton should be made ... at the top tier of your application and in loggers 

http://tech.puredanger.com/2007/07/03/pattern-hate-singleton/</description>
		<content:encoded><![CDATA[<p>Hi Bill, i know that singleton is the class and the pattern is Singleton but ok .. i didn-t explain myself correctly.<br />
by the way<br />
&#8221;<br />
* The Abstract Factory, Builder, and Prototype patterns can use Singletons in their implementation.<br />
    * Facade objects are often Singletons because only one Facade object is required.<br />
    * State objects are often Singletons.<br />
    * Singletons are often preferred to global variables because:<br />
          o They don&#8217;t pollute the global namespace (or, in languages with namespaces, their containing namespace) with unnecessary variables.[7]<br />
          o They permit lazy allocation and initialization, where global variables in many languages will always consume resources.<br />
&#8221;<br />
this according to wikipedia.<br />
<a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow">http://en.wikipedia.org/wiki/Singleton_pattern</a><br />
but as a personal experience using the Singleton Pattern if i use it at an higher level in my app it does permit loose coupling the problem with Actionscript like it was said before is that Actionscript doesn&#8217;t really have a correct way to implement it. There are hacks to it,Grant Skinner and others have largely blogged about it.</p>
<p>The thing about the Singleton Pattern according to standards is that is makes the Application not to follow a principal like a class having a single responsability.</p>
<p>Should a principle be a law ? does it mean i have to have just one responsability in a class</p>
<p>the Singleton Pattern definition says:<br />
&#8220;Singleton is a class which permits itself to be instantiated only once. It…</p>
<p>        * has a private or protected constructor with no parameters.<br />
        * has a single, global means of access via a static method.<br />
        * cannot be subclassed nor instantiated with the new operator.<br />
        * uses lazy instantiation.<br />
&#8221;<br />
&#8221;<br />
Singleton can be used—in fact, is required—in many situations, for example:</p>
<p>        * caches<br />
        * device drivers<br />
        * dialog boxes<br />
        * loggers<br />
        * thread pools </p>
<p>&#8221;</p>
<p>so is it really that bad to use a Singleton ? </p>
<p>furthermore i found an excellent entrie on the subject and yes it bashes the GOF Singleton Pattern but it also states that there are some places where the use of the Singleton should be made &#8230; at the top tier of your application and in loggers </p>
<p><a href="http://tech.puredanger.com/2007/07/03/pattern-hate-singleton/" rel="nofollow">http://tech.puredanger.com/2007/07/03/pattern-hate-singleton/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William B. Sanders</title>
		<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/comment-page-1/#comment-2917</link>
		<dc:creator>William B. Sanders</dc:creator>
		<pubDate>Thu, 10 Sep 2009 19:41:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=1424#comment-2917</guid>
		<description>Hi Hugo,

I believe that you&#039;re mixing Singletons as a design pattern and singletons as a single class within a system or pattern. Just to help us communicate, the class is capitalized (Singleton), and the single class is not capitalized (singleton).

Nothing I&#039;ve said or other critics of the Singleton have said applies to singletons. So while each state implementation in a State design pattern is a singleton; none are Singletons.

Good to hear from you and thanks for your comments,
Bill</description>
		<content:encoded><![CDATA[<p>Hi Hugo,</p>
<p>I believe that you&#8217;re mixing Singletons as a design pattern and singletons as a single class within a system or pattern. Just to help us communicate, the class is capitalized (Singleton), and the single class is not capitalized (singleton).</p>
<p>Nothing I&#8217;ve said or other critics of the Singleton have said applies to singletons. So while each state implementation in a State design pattern is a singleton; none are Singletons.</p>
<p>Good to hear from you and thanks for your comments,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hugo</title>
		<link>http://www.as3dp.com/2009/09/01/saint-singleton-have-we-martyred-design-pattern-unfairly/comment-page-1/#comment-2916</link>
		<dc:creator>Hugo</dc:creator>
		<pubDate>Thu, 10 Sep 2009 15:07:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=1424#comment-2916</guid>
		<description>Hi Bill and hi everybody,

Hierarchical State Machines and State Machine patterns use singletons ( states are singletons ), some aspect oriented design and separation of concern designs use singletons and aren&#039;t that bad. What i want to say here is that singletons can and should be used if their use is appropriate, singletons are present in the Facade pattern and permit loose coupling. it all depends on the way you feel more confortable developing sometimes using a singleton is just great!</description>
		<content:encoded><![CDATA[<p>Hi Bill and hi everybody,</p>
<p>Hierarchical State Machines and State Machine patterns use singletons ( states are singletons ), some aspect oriented design and separation of concern designs use singletons and aren&#8217;t that bad. What i want to say here is that singletons can and should be used if their use is appropriate, singletons are present in the Facade pattern and permit loose coupling. it all depends on the way you feel more confortable developing sometimes using a singleton is just great!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
