<?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/"
	>

<channel>
	<title>ActionScript 3.0 Design Patterns &#187; Design Pattern Tours</title>
	<atom:link href="http://www.as3dp.com/category/design-pattern-tours/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.as3dp.com</link>
	<description>OOP Techniques for Flash and Flex Developers</description>
	<lastBuildDate>Sun, 29 Jan 2012 17:00:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The ActionScript 3.0 Design Pattern Thrill Ride: Part II—Catalyst</title>
		<link>http://www.as3dp.com/2010/03/the-actionscript-3-0-design-pattern-thrill-ride-part-ii-catalyst/</link>
		<comments>http://www.as3dp.com/2010/03/the-actionscript-3-0-design-pattern-thrill-ride-part-ii-catalyst/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 20:09:50 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[Design Pattern Tours]]></category>
		<category><![CDATA[State]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=2892</guid>
		<description><![CDATA[I&#8217;ve been working on a project with Adobe Catalyst, and if I didn&#8217;t do something for a Design Pattern tour now, it would be put off until I don&#8217;t know when. So I put together a non-design pattern application incorporating video and code snippets from the Aid Game. I simply have not had time (given [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.as3dp.com/wp-content/uploads/2010/02/Thrill.png" alt="Thrill" title="Thrill" width="300" height="144" class="alignleft size-full wp-image-2852" /> I&#8217;ve been working on a project with Adobe Catalyst, and if I didn&#8217;t do something for a Design Pattern tour now, it would be put off until I don&#8217;t know when. So I put together a non-design pattern application incorporating video and code snippets from the <a href="http://www.as3dp.com/2010/02/02/new-aid-game-the-machine-moves/">Aid Game</a>. I simply have not had time (given the work I&#8217;m doing with Catalyst) to put together a more generic design pattern &#8220;thrill ride&#8221; that I planned; so while I&#8217;m working with Catalyst, I thought I&#8217;d might as well do something with design patterns and came up with this more mild tour instead of my planned thrill ride. Figure 1 shows what it looks like:<br />
<div id="attachment_2893" class="wp-caption alignnone" style="width: 510px"><img src="http://www.as3dp.com/wp-content/uploads/2010/03/complex.png" alt="&lt;em&gt;&lt;strong&gt;Figure 1: &lt;/strong&gt;Tour through State Design Pattern&lt;/em&gt;" title="complex" width="500" height="439" class="size-full wp-image-2893" /><p class="wp-caption-text"><em><strong>Figure 1: </strong>Tour through State Design Pattern</em></p></div></p>
<p>As you can see it&#8217;s pretty simple—sort of a PowerPoint chat. (Nowhere near as flexible as the one created with the <a href="http://www.as3dp.com/category/design-patterns/memento/">Memento</a> pattern.) So, if you&#8217;re interested in a mild tour, click the Play button and hop on:<br />
<a href="http://nemo.mwd.hartford.edu/~wsanders/stateride/"><img src="http://www.as3dp.com/wp-content/uploads/2009/12/play.jpg" alt="play" title="play" width="106" height="46" class="alignnone size-full wp-image-2255" /></a></p>
<p>By the way, the Catalyst project has made me far more aware of Flash Builder/Flex code. It uses Flex in its engine. If you&#8217;re interested in Catalyst, you can <a href="http://labs.adobe.com/technologies/flashcatalyst/">download the Beta at Adobe Labs</a>. I tried importing programs (SWF files) made with design patterns, and it works great. About the only thing I didn&#8217;t do with this tour is to put the videos on Flash Media Server—sorry. I was in a hurry and wasn&#8217;t sure how to link up FMS to Catalyst. I could have written the code in Flash/Flex and created an SWF file to import into Catalyst, and that works fine, but I&#8217;m pretty pressed for time on this project.</p>
<p>As always, your comments and valuable feedback is encouraged. I&#8217;ll be back working on this blog as soon as I&#8217;m finished with the Catalyst project. Besides, Chandima has been writing knock-out posts to keep you interested!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2010%2F03%2Fthe-actionscript-3-0-design-pattern-thrill-ride-part-ii-catalyst%2F&amp;title=The%20ActionScript%203.0%20Design%20Pattern%20Thrill%20Ride%3A%20Part%20II%E2%80%94Catalyst" id="wpa2a_2"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2010/03/the-actionscript-3-0-design-pattern-thrill-ride-part-ii-catalyst/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The ActionScript 3.0 Design Pattern Thrill Ride: Part I</title>
		<link>http://www.as3dp.com/2010/02/the-actionscript-3-0-design-pattern-thrill-ride-part-i/</link>
		<comments>http://www.as3dp.com/2010/02/the-actionscript-3-0-design-pattern-thrill-ride-part-i/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 21:04:03 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[Design Pattern Tours]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=2812</guid>
		<description><![CDATA[My initial idea of having a &#8220;thrill ride&#8221; through a design pattern to help reveal its operation is turning out to be awkward in more ways than I envisioned. The initial tour is going to be through a State Design Pattern; so naturally I set it up using a State pattern. It wasn&#8217;t too long [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.as3dp.com/wp-content/uploads/2010/02/Thrill.png" alt="Thrill" title="Thrill" width="300" height="144" class="alignleft size-full wp-image-2852" />My initial idea of having a &#8220;thrill ride&#8221; through a design pattern to help reveal its operation is turning out to be awkward in more ways than I envisioned. The initial tour is going to be through a State Design Pattern; so naturally I set it up using a State pattern. It wasn&#8217;t too long before I realized that it would be difficult to visit all of the participants without adding new states that would show visiting the Context and State interface. In other words, I needed  <strong>VisitContext</strong> and <strong>VisitState</strong> state classes.</p>
<p>After some fumbling, I saw that much of the important work is done by the Client. It actually works like a composer, especially since the State design is a beautiful example of both composition and delegation. Each participant had some responsibility in the process that I wanted to reveal in the sequence in which it occurs. With the State design, this is especially challenging because the context changes with each state. So how does one go about making a tour of such a process?</p>
<p><strong>What Varies?</strong></p>
<p>Then it occurred to me that were I to spend time on setting up a tour of the State design pattern, why not create a reusable application that I could use on any pattern I wanted? Of course this brought me back to the most basic question of design pattern development—what varies? In other words what varies in a tour of a pattern? So I whipped out my <a href="http://www.as3dp.com/2009/06/12/the-developing-an-air-actionscript-30-design-pattern-catalog-and-the-air-magic-table/">Magic Table</a> to look at the possible variations in a design pattern.  Well, I knew that the patterns were going to vary, but what does that look like in the Magic Table? Here were some that stood out:</p>
<ul>
<li>Algorithms—<a href="http://www.as3dp.com/2009/03/08/actionscript-30-easy-and-practical-strategy-design-pattern/">Strategy</a></li>
<li>Steps of an Algorithm—<a href="http://www.as3dp.com/2009/05/07/hollywood-principle-don’t-call-us-we’ll-call-you—actionscript-30-template-design-pattern-goes-hollywood/">Template Method</a></li>
<li>When and how a request is fulfilled—Command</li>
<li>Object that can fill a request—<a href="http://www.as3dp.com/2008/01/14/actionscript-30-chain-of-responsibility-design-pattern-decoupling-request-and-request-handler/">Chain of Responsibility</a></li>
<li>States of an Object—<a href="http://www.as3dp.com/2010/02/02/new-aid-game-the-machine-moves/">State</a></li>
</ul>
<p>I&#8217;ll get to the decisions involved in deciding on the best design pattern for making my <em>thrill ride</em> through different design patterns in a bit, but first, I wanted to consider the initial animations, graphics and design. The embedded SWF shows what I have in mind. The &#8220;control panel&#8221; is made up of buttons representing the different states (The animation just goes from the Client to the Context but it gives an idea of the animation I&#8217;m considering. It only goes to one state and then this page has to be reloaded to start over.)</p>
<p>[swfobj src="http://www.as3dp.com/wp-content/uploads/2010/02/ClientTest4.swf" align="none" allowfullscreen="true"]<br />
<span id="more-2812"></span><br />
As you can see, the &#8220;view&#8221; from the &#8220;control panel&#8221; is the next participant in the design pattern. Also, an <strong>acquaintance arrow</strong> appears from the current view to the Context state in the &#8220;distance.&#8221; When you click one of the buttons on the panel, the view moves into the Context state and the State interface appears with an <strong>aggregation arrow</strong> from the current view.</p>
<p><strong>Culling The Sequence</strong></p>
<p>The idea is to move &#8220;into&#8221; the next participant (class or interface) and show what happens when the moves occur. So far all I have is a partial jump from the Client into the Context class, but I want to show what happens when that step is taken. Figure 1 shows a sequence each request goes through and I&#8217;m trying to work out a way to animate the whole thing using a design pattern.<br />
<div id="attachment_2828" class="wp-caption alignnone" style="width: 482px"><img src="http://www.as3dp.com/wp-content/uploads/2010/02/StateThrillRideSequence.png" alt="&lt;em&gt;&lt;strong&gt;Figure 1: &lt;/strong&gt; Sequence of request in State design&lt;/em&gt;" title="StateThrillRideSequence" width="472" height="240" class="size-full wp-image-2828" /><p class="wp-caption-text"><em><strong>Figure 1: </strong> Sequence of request in State design</em></p></div></p>
<p>You can see a 5-step sequence with each request in a State design pattern. In the particular one we&#8217;re using in the example, we also have some helper classes in the form of a helicopter from the Library and a Mover object that moves the helicopter. The helper classes aid the in overall decoupling in the pattern.</p>
<p>To make an interesting trip through design patterns I&#8217;m forced to think in terms of a sequence to illustrate what is not sequential programming, but rather the process of composition and use and re-use of the objects making up design patterns. However, roller coasters and other theme park rides roll along sequentially and so I&#8217;m trying to step through the code dynamically as it is used. Once I get the basic implementation set up I can re-use it to trace through other design patterns.</p>
<p><strong>Back to the Variation</strong></p>
<p>Okay, we&#8217;ve got to ask once again <strong><em>What&#8217;s the fluctuation?</em></strong> (WTF?) After our examination of the steps in a request through a State design, we see a set of requests handled by the participants. That variation (or fluctuation) in a sequence looks a lot like a trip through a Chain of Responsibility pattern. The CoR sequence can be seen in Figure 2: <div id="attachment_2165" class="wp-caption alignleft" style="width: 250px"><img src="http://www.as3dp.com/wp-content/uploads/2009/11/smallchain.png" alt="&lt;em&gt;&lt;strong&gt;Figure 2: &lt;/strong&gt; CoR Pattern can handle a sequence&lt;/em&gt;" title="smallchain" width="240" height="90" class="size-full wp-image-2165" /><p class="wp-caption-text"><em><strong>Figure 2: </strong> CoR  sequence</em></p></div> Why not use it? As each step in the sequence is reached, the CoR makes a call to the appropriate object that shows what happens in the pattern by the appropriate participant. By treating each step as a request, we can handle virtually any sequence. That should serve us well when working up a way to take a trip through all of the different patterns.</p>
<p><strong>Your Thoughts?</strong></p>
<p>You can see where I am right now and where I have to go to get the ride moving. So I&#8217;d appreciate any ideas or help (especially with the artwork) that you may have. The look and feel is important for this to work well. Here&#8217;s where you can help:</p>
<ul>
<li>Suggested design patterns that would work better than CoR</li>
<li>Ideas about how this should work—the animation, look and feel</li>
<li>What should be included in each step of the sequence</li>
<li>Artwork in the form of something I can use for a &#8220;dashboard&#8221; and scenes</li>
</ul>
<p>Also, I&#8217;d like your thoughts on how helpful this will be. I know that sometimes I can trip over my own feet by being too clever. My favorite design pattern book is the Freemans&#8217; <em>Head First Design Patterns</em>, but sometimes, their explanations got lost in the cleverness of the <strong>Head First</strong> framework. So, if you think this is a fool&#8217;s errand, let me know.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2010%2F02%2Fthe-actionscript-3-0-design-pattern-thrill-ride-part-i%2F&amp;title=The%20ActionScript%203.0%20Design%20Pattern%20Thrill%20Ride%3A%20Part%20I" id="wpa2a_4"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2010/02/the-actionscript-3-0-design-pattern-thrill-ride-part-i/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

