<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>H1DD3N.R350URC3 &#187; Design Patterns</title>
	<atom:link href="http://blog.hexagonstar.com/tag/design-patterns/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hexagonstar.com</link>
	<description>&#34;Chaotic Neutral&#34;</description>
	<lastBuildDate>Wed, 03 Mar 2010 04:56:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
    <title>H1DD3N.R350URC3</title>
    <url>http://blog.hexagonstar.com/feed-logo.png</url>
    <link>http://blog.hexagonstar.com</link>
    <width>144</width>
    <height>36</height>
    <description>H1DD3N.R350URC3 - http://blog.hexagonstar.com</description>
    </image>		<item>
		<title>Waterproof AS 3.0 Singleton</title>
		<link>http://blog.hexagonstar.com/waterproof_as3_singleton/</link>
		<comments>http://blog.hexagonstar.com/waterproof_as3_singleton/#comments</comments>
		<pubDate>Fri, 24 Nov 2006 14:22:48 +0000</pubDate>
		<dc:creator>sascha</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://blog.hexagonstar.com/waterproof-as-30-singleton/</guid>
		<description><![CDATA[While reading Advanced ActionScript 3 with Design Patterns I&#8217;ve once again came across the AS 3.0 Singleton solution that has to deal with the absence of private constructors (I&#8217;ll save my rage and cursings about who had the idea to remove them for now  ) and while the authors are using the already well ]]></description>
			<content:encoded><![CDATA[<p>While reading <a href="http://hiddenresource.corewatch.net/archives/69">Advanced ActionScript 3 with Design Patterns</a> I&#8217;ve once again came across the AS 3.0 Singleton solution that has to deal with the absence of private constructors (I&#8217;ll save my rage and cursings about who had the idea to remove them for now <img src='http://blog.hexagonstar.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) and while the authors are using the already well known method of using a SingletonEnforcer class outside the Singleton&#8217;s package to verify that the class cannot be  instanciated via the constructor they also note that this can be doublecrossed by giving <strong>null </strong>or <strong>undefined </strong>as a constructor parameter. As this is rather sub optimal I was wondering why they don&#8217;t just check inside the Singleton constructor for a null/undefined argument and throw an exception accordingly?!<br />
I&#8217;m sure somebody else had the same idea already but here&#8217;s my idea of a waterproof Singleton class that cannot be misused from the outside (As always, if I missed any detail that accidentally breaks hell loose feel free to correct me) &#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> WaterproofSingleton <span style="color: #000000;">&#123;</span>
		static <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _instance<span style="color: #000000; font-weight: bold;">:</span>Singleton;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Singleton<span style="color: #000000;">&#40;</span>singletonEnforcer<span style="color: #000000; font-weight: bold;">:</span>SingletonEnforcer<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>singletonEnforcer <span style="color: #0033ff; font-weight: bold;">as</span> SingletonEnforcer<span style="color: #000000;">&#41;</span> == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Direct instantiation of a Singleton is not allowed!&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>Singleton <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Singleton._instance == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				Singleton._instance = <span style="color: #0033ff; font-weight: bold;">new</span> Singleton<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> SingletonEnforcer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> Singleton._instance;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #9900cc; font-weight: bold;">class</span> SingletonEnforcer <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<img src="http://blog.hexagonstar.com/?ak_action=api_record_view&id=119&type=feed" alt="" /><br /><small>© 2006 <a href="http://blog.hexagonstar.com">H1DD3N.R350URC3</a>. | <a href="http://blog.hexagonstar.com/waterproof_as3_singleton/">Permalink</a> | <a href="http://blog.hexagonstar.com/waterproof_as3_singleton/#comments">6 comments</a> | Tags: <a href="http://blog.hexagonstar.com/tag/actionscript/" rel="tag">ActionScript</a>, <a href="http://blog.hexagonstar.com/tag/design-patterns/" rel="tag">Design Patterns</a>, <a href="http://blog.hexagonstar.com/tag/source-code/" rel="tag">Source Code</a> | Add to <a href="http://del.icio.us/post?url=http://blog.hexagonstar.com/waterproof_as3_singleton/&title=Waterproof AS 3.0 Singleton">del.icio.us</a></small>]]></content:encoded>
			<wfw:commentRss>http://blog.hexagonstar.com/waterproof_as3_singleton/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Learn some patterns &#8211; Advanced ActionScript 3.0 with Design Patterns</title>
		<link>http://blog.hexagonstar.com/learn-some-patterns-advanced-actionscript-30-with-design-patterns/</link>
		<comments>http://blog.hexagonstar.com/learn-some-patterns-advanced-actionscript-30-with-design-patterns/#comments</comments>
		<pubDate>Thu, 23 Nov 2006 11:16:39 +0000</pubDate>
		<dc:creator>sascha</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Random Picks]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://blog.hexagonstar.com/learn-some-patterns-advanced-actionscript-30-with-design-patterns/</guid>
		<description><![CDATA[I&#8217;ve been reading this book by Joey Lott and Danny Patterson since yesterday and thought I&#8217;d loose a couple of words about it &#8230;
The book starts with a chapter about application design where it explains how to go through the analysis-, design- , implementation and testing phase. It introduces how to utilize Use Case- and ]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-229 alignright" style="float: right;" src="http://blog.hexagonstar.com/wp-content/uploads/aas3dpcover.jpg" alt="" width="100" height="123" />I&#8217;ve been reading <a href="http://www.adobepress.com/bookstore/product.asp?isbn=0321477731&amp;rl=1">this book</a> by Joey Lott and Danny Patterson since yesterday and thought I&#8217;d loose a couple of words about it &#8230;<br />
The book starts with a chapter about application design where it explains how to go through the analysis-, design- , implementation and testing phase. It introduces how to utilize Use Case- and Class Diagrams and then gives a lesson on how to use FlexUnit for unit testing. In the second chapter is a good explanation about why and how to use Interfaces (instead of Inheritance) and after that it goes into detail with teaching nine of the more common Design Patterns, namely MVC, Singleton, Factory/Template Method, Proxy, Iterator, Composite, Decorator, Command, Memento and State. In part 3 of the book you&#8217;ll find in-depth information about AS 3.0 features like Events, data IO, E4X and Regular Expressions.</p>
<p>>> <a href="http://blog.hexagonstar.com/learn-some-patterns-advanced-actionscript-30-with-design-patterns/">Continue reading "Learn some patterns &#8211; Advanced ActionScript 3.0 with Design Patterns"</a></p>
<br /><small>© 2006 <a href="http://blog.hexagonstar.com">H1DD3N.R350URC3</a>. | <a href="http://blog.hexagonstar.com/learn-some-patterns-advanced-actionscript-30-with-design-patterns/">Permalink</a> | <a href="http://blog.hexagonstar.com/learn-some-patterns-advanced-actionscript-30-with-design-patterns/#comments">1 comment</a> | Tags: <a href="http://blog.hexagonstar.com/tag/actionscript/" rel="tag">ActionScript</a>, <a href="http://blog.hexagonstar.com/tag/books/" rel="tag">Books</a>, <a href="http://blog.hexagonstar.com/tag/design-patterns/" rel="tag">Design Patterns</a>, <a href="http://blog.hexagonstar.com/tag/flash/" rel="tag">Flash</a>, <a href="http://blog.hexagonstar.com/tag/oop/" rel="tag">OOP</a> | Add to <a href="http://del.icio.us/post?url=http://blog.hexagonstar.com/learn-some-patterns-advanced-actionscript-30-with-design-patterns/&title=Learn some patterns &#8211; Advanced ActionScript 3.0 with Design Patterns">del.icio.us</a></small>]]></content:encoded>
			<wfw:commentRss>http://blog.hexagonstar.com/learn-some-patterns-advanced-actionscript-30-with-design-patterns/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Understanding Interfaces and Polymorphism</title>
		<link>http://blog.hexagonstar.com/understanding-interfaces-and-polymorphism/</link>
		<comments>http://blog.hexagonstar.com/understanding-interfaces-and-polymorphism/#comments</comments>
		<pubDate>Sat, 18 Nov 2006 11:12:58 +0000</pubDate>
		<dc:creator>sascha</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://blog.hexagonstar.com/understanding-interfaces-and-polymorphism/</guid>
		<description><![CDATA[I&#8217;ve been using Interfaces a couples of time now when needed but I never fully understood those down-sized Class construct wannabes. I knew they are useful when it is required to have an universal type for different objects but I haven&#8217;t fully grasped to scope why they are so useful otherwise. Also the fact that ]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Interfaces a couples of time now when needed but I never fully understood those down-sized Class construct wannabes. I knew they are useful when it is required to have an universal type for different objects but I haven&#8217;t fully grasped to scope why they are so useful otherwise. Also the fact that they can&#8217;t contain properties and only public method declarations confused me.</p>
<p>>> <a href="http://blog.hexagonstar.com/understanding-interfaces-and-polymorphism/">Continue reading "Understanding Interfaces and Polymorphism"</a></p>
<br /><small>© 2006 <a href="http://blog.hexagonstar.com">H1DD3N.R350URC3</a>. | <a href="http://blog.hexagonstar.com/understanding-interfaces-and-polymorphism/">Permalink</a> | <a href="http://blog.hexagonstar.com/understanding-interfaces-and-polymorphism/#comments">2 comments</a> | Tags: <a href="http://blog.hexagonstar.com/tag/actionscript/" rel="tag">ActionScript</a>, <a href="http://blog.hexagonstar.com/tag/books/" rel="tag">Books</a>, <a href="http://blog.hexagonstar.com/tag/coding/" rel="tag">Coding</a>, <a href="http://blog.hexagonstar.com/tag/design-patterns/" rel="tag">Design Patterns</a>, <a href="http://blog.hexagonstar.com/tag/oop/" rel="tag">OOP</a> | Add to <a href="http://del.icio.us/post?url=http://blog.hexagonstar.com/understanding-interfaces-and-polymorphism/&title=Understanding Interfaces and Polymorphism">del.icio.us</a></small>]]></content:encoded>
			<wfw:commentRss>http://blog.hexagonstar.com/understanding-interfaces-and-polymorphism/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
