<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>Comments for ActionScript 3.0 Design Patterns</title>
	
	<link>http://www.as3dp.com</link>
	<description>OOP Techniques for Flash and Flex Developers</description>
	<lastBuildDate>Mon, 13 Feb 2012 17:14:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CommentsForActionscript3DesignPatterns" /><feedburner:info uri="commentsforactionscript3designpatterns" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>Comment on The Grid State: Movement in Mobile by William B. Sanders</title>
		<link>http://www.as3dp.com/2012/02/the-grid-state-movement-in-mobile/#comment-2146</link>
		<dc:creator>William B. Sanders</dc:creator>
		<pubDate>Mon, 13 Feb 2012 17:14:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=6333#comment-2146</guid>
		<description>Hi again Archont,

Thanks for your reply. You made several good points. Let me clarify a couple of things. First, the "attack" button and actions are just "place holders" until I decide what I want to do with the combat portion. In fact the entire Client class is just a platform for making requests. Second, changing anything in the Client for calls to the State machine does not change the State pattern, and all of your points on event handlers are quite helpful.

Where we may disagree is the role of the structure and highly specialized algorithms (or not-so-specialized algorithms). The idea of programming to the interface instead of the implementation implies flexibility in methods. So, I would think that highly specialized algorithms that implement an interface would both maintain the structure without crashing the other parts of the program. The alternative would be a delicately balanced set of algorithms strung together by conditional statements, which have their own set of issues. Changing an algorithm in a conditional based system would seem to be far more tricky to maintain and/or extend than one in a State Pattern where there are no conditional statements (outside of the Client). You could use array or vector objects for storage, but I'm not sure why. I've used both in State Patterns, but I did not see a use for them here.

As for a better event handler, I'm all ears. I had to cut back on anything that moved in the SimpleButton objects to improve Touch responses, but like you said, slugs move faster than AS event handlers.

So if you have the few minutes, I'd like to see your redo.

Kindest regards,
Bill</description>
		<content:encoded><![CDATA[<p>Hi again Archont,</p>
<p>Thanks for your reply. You made several good points. Let me clarify a couple of things. First, the &#8220;attack&#8221; button and actions are just &#8220;place holders&#8221; until I decide what I want to do with the combat portion. In fact the entire Client class is just a platform for making requests. Second, changing anything in the Client for calls to the State machine does not change the State pattern, and all of your points on event handlers are quite helpful.</p>
<p>Where we may disagree is the role of the structure and highly specialized algorithms (or not-so-specialized algorithms). The idea of programming to the interface instead of the implementation implies flexibility in methods. So, I would think that highly specialized algorithms that implement an interface would both maintain the structure without crashing the other parts of the program. The alternative would be a delicately balanced set of algorithms strung together by conditional statements, which have their own set of issues. Changing an algorithm in a conditional based system would seem to be far more tricky to maintain and/or extend than one in a State Pattern where there are no conditional statements (outside of the Client). You could use array or vector objects for storage, but I&#8217;m not sure why. I&#8217;ve used both in State Patterns, but I did not see a use for them here.</p>
<p>As for a better event handler, I&#8217;m all ears. I had to cut back on anything that moved in the SimpleButton objects to improve Touch responses, but like you said, slugs move faster than AS event handlers.</p>
<p>So if you have the few minutes, I&#8217;d like to see your redo.</p>
<p>Kindest regards,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The Grid State: Movement in Mobile by archont</title>
		<link>http://www.as3dp.com/2012/02/the-grid-state-movement-in-mobile/#comment-2145</link>
		<dc:creator>archont</dc:creator>
		<pubDate>Mon, 13 Feb 2012 14:50:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=6333#comment-2145</guid>
		<description>&gt;First of all, it does not matter whether the device is mobile or desktop as far as Design Patterns are concerned. Good or bad algorithms can go into good or bad structures.

Algorithms are separate from design patterns, are they not? Games require highly optimized and often very special-purpose algorithms. But design patterns, in my understanding, are more about creating higher levels of abstraction to better conceptualize the relationships in the program in order to facilitate quicker coding. 

However the downside of design patterns is that they lock down the code (meaning by setting out how objects interact using a specific pattern) it's hard to quickly adapt the objects to use a different relationship without doing a full nuke&amp;pave. But that's not the real problem, a lot of the code can be taken for granted and won't be changed, so patterns are appropriate there.

The real problem comes with efficiency. Sure, some patterns like the object pool, vectors, maps, signals and so on are great tools but high-level patterns need to be used with caution. Using design patterns for rarely executed code is fine. A game menu or inventory screen is a great place to use patterns. The main meat of the engine, the rendering code and the frame loop are not. 

As for creating better code - sure, a few examples of what I'd do:

1) remove the repetition in westnow, eastnow, northnow and southnow. I don't like pasting code. The map changing logic would be moved to another function, moveAvatar(deltaX:int, deltaY:int=0):void

The event handlers would just call a variation of moveAvatar(-1) or moveAvatar(0,1);

2) go further with no. 1 and remove all game logic from event handler functions. Imagine I have to implement a cutscene where the PC attacks an NPC. Would I have to do an attackNow(theEventIJustCreated); ? It's my own coding practice to have event handlers call functions that do the real action. Since the event handling model in Flash is glacially slow anyway I might as well afford the luxury of decoupling. In time-critical situations I use nativesignals. 

3) Use an Array or Vector for storing grids. Support for various map sizes out of the box. 

I might actually go and redo this code if I have a few minutes today.</description>
		<content:encoded><![CDATA[<p>&gt;First of all, it does not matter whether the device is mobile or desktop as far as Design Patterns are concerned. Good or bad algorithms can go into good or bad structures.</p>
<p>Algorithms are separate from design patterns, are they not? Games require highly optimized and often very special-purpose algorithms. But design patterns, in my understanding, are more about creating higher levels of abstraction to better conceptualize the relationships in the program in order to facilitate quicker coding. </p>
<p>However the downside of design patterns is that they lock down the code (meaning by setting out how objects interact using a specific pattern) it&#8217;s hard to quickly adapt the objects to use a different relationship without doing a full nuke&amp;pave. But that&#8217;s not the real problem, a lot of the code can be taken for granted and won&#8217;t be changed, so patterns are appropriate there.</p>
<p>The real problem comes with efficiency. Sure, some patterns like the object pool, vectors, maps, signals and so on are great tools but high-level patterns need to be used with caution. Using design patterns for rarely executed code is fine. A game menu or inventory screen is a great place to use patterns. The main meat of the engine, the rendering code and the frame loop are not. </p>
<p>As for creating better code &#8211; sure, a few examples of what I&#8217;d do:</p>
<p>1) remove the repetition in westnow, eastnow, northnow and southnow. I don&#8217;t like pasting code. The map changing logic would be moved to another function, moveAvatar(deltaX:int, deltaY:int=0):void</p>
<p>The event handlers would just call a variation of moveAvatar(-1) or moveAvatar(0,1);</p>
<p>2) go further with no. 1 and remove all game logic from event handler functions. Imagine I have to implement a cutscene where the PC attacks an NPC. Would I have to do an attackNow(theEventIJustCreated); ? It&#8217;s my own coding practice to have event handlers call functions that do the real action. Since the event handling model in Flash is glacially slow anyway I might as well afford the luxury of decoupling. In time-critical situations I use nativesignals. </p>
<p>3) Use an Array or Vector for storing grids. Support for various map sizes out of the box. </p>
<p>I might actually go and redo this code if I have a few minutes today.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The Grid State: Movement in Mobile by William B. Sanders</title>
		<link>http://www.as3dp.com/2012/02/the-grid-state-movement-in-mobile/#comment-2144</link>
		<dc:creator>William B. Sanders</dc:creator>
		<pubDate>Mon, 13 Feb 2012 14:13:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=6333#comment-2144</guid>
		<description>Hi Archont,

First of all, it does not matter whether the device is mobile or desktop as far as Design Patterns are concerned. Good or bad algorithms can go into good or bad structures.(See http://www.as3dp.com/2011/03/beginners-oop-design-patterns-in-actionscript-3-0-post-1-rolls-royces-in-the-junk-yard/) There's no over-engineering going on, and if you can show me a better way to create a design for self-aware state, I'd like to see it.

Second, there's no problem starting with a Q&amp;D prototype. I usually do as well, and then I look to see a way that I could do it so that there's loose binding and easy to update. Like you, I've pulled out Occam's Razor when it comes to writing code for mobile.

I suppose it depends on which Real World you live in. Design Patterns were developed for Programming in the Read World where the size of the programs are big and changeable. None of us think that the limitations on these early mobile devices will be restrictive forever.

Let's see a better way to create inter-cell movement in a grid.

Kindest regards,
Bill</description>
		<content:encoded><![CDATA[<p>Hi Archont,</p>
<p>First of all, it does not matter whether the device is mobile or desktop as far as Design Patterns are concerned. Good or bad algorithms can go into good or bad structures.(See <a href="http://www.as3dp.com/2011/03/beginners-oop-design-patterns-in-actionscript-3-0-post-1-rolls-royces-in-the-junk-yard/" rel="nofollow">http://www.as3dp.com/2011/03/beginners-oop-design-patterns-in-actionscript-3-0-post-1-rolls-royces-in-the-junk-yard/</a>) There&#8217;s no over-engineering going on, and if you can show me a better way to create a design for self-aware state, I&#8217;d like to see it.</p>
<p>Second, there&#8217;s no problem starting with a Q&#038;D prototype. I usually do as well, and then I look to see a way that I could do it so that there&#8217;s loose binding and easy to update. Like you, I&#8217;ve pulled out Occam&#8217;s Razor when it comes to writing code for mobile.</p>
<p>I suppose it depends on which Real World you live in. Design Patterns were developed for Programming in the Read World where the size of the programs are big and changeable. None of us think that the limitations on these early mobile devices will be restrictive forever.</p>
<p>Let&#8217;s see a better way to create inter-cell movement in a grid.</p>
<p>Kindest regards,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The Grid State: Movement in Mobile by archont</title>
		<link>http://www.as3dp.com/2012/02/the-grid-state-movement-in-mobile/#comment-2143</link>
		<dc:creator>archont</dc:creator>
		<pubDate>Mon, 13 Feb 2012 12:39:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=6333#comment-2143</guid>
		<description>Hey,

While I use design patterns of all sorts in desktop and web applications I'm afraid that the role of design patterns is limited in game development. That applies double so for mobile games.

In game development the best cycle I've found is to first create a quick and dirty prototype - and by dirty I mean GOTO dirty, if that speeds up the workflow. Once the prototype is fun and playable comes refactoring. But since game logic is pretty convoluted and messy you never know which way you'll want to expand the code. Maybe you'll want to completely rewrite arrows from a vector of data objects (the C equivalent of struct) to classes that extend PhysicsTask. Sometimes proper coding practices get in the way of optimization - function calls are costly in AS3. 

The important thing - you need to make it clear that what you're doing doesn't apply to the Real World. This kind of overengineering at the prototype level gets in the way of creating the actual fun in the game. It's a good way to show specific design patterns on an interactive example that looks interesting but this is certainly not the way to create games, ever.

Cheers</description>
		<content:encoded><![CDATA[<p>Hey,</p>
<p>While I use design patterns of all sorts in desktop and web applications I&#8217;m afraid that the role of design patterns is limited in game development. That applies double so for mobile games.</p>
<p>In game development the best cycle I&#8217;ve found is to first create a quick and dirty prototype &#8211; and by dirty I mean GOTO dirty, if that speeds up the workflow. Once the prototype is fun and playable comes refactoring. But since game logic is pretty convoluted and messy you never know which way you&#8217;ll want to expand the code. Maybe you&#8217;ll want to completely rewrite arrows from a vector of data objects (the C equivalent of struct) to classes that extend PhysicsTask. Sometimes proper coding practices get in the way of optimization &#8211; function calls are costly in AS3. </p>
<p>The important thing &#8211; you need to make it clear that what you&#8217;re doing doesn&#8217;t apply to the Real World. This kind of overengineering at the prototype level gets in the way of creating the actual fun in the game. It&#8217;s a good way to show specific design patterns on an interactive example that looks interesting but this is certainly not the way to create games, ever.</p>
<p>Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on From ActionScript 3.0 to JavaScript Chain of Responsibility: Part II The Help Desk by William B. Sanders</title>
		<link>http://www.as3dp.com/2012/01/from-actionscript-3-0-to-javascript-chain-of-responsibility-part-ii-the-help-desk/#comment-2105</link>
		<dc:creator>William B. Sanders</dc:creator>
		<pubDate>Sun, 29 Jan 2012 19:34:31 +0000</pubDate>
		<guid isPermaLink="false">http://new.as3dp.com/?p=6352#comment-2105</guid>
		<description>Hey Mercadeo!

¿Did I just get spammed en Español? ¡Ay, caramba!  ¿Que pasa?

Memo....</description>
		<content:encoded><![CDATA[<p>Hey Mercadeo!</p>
<p>¿Did I just get spammed en Español? ¡Ay, caramba!  ¿Que pasa?</p>
<p>Memo&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on ActionScript 3.0 Single Class Event Handler by William B. Sanders</title>
		<link>http://www.as3dp.com/2012/01/actionscript-3-0-single-class-event-handler/#comment-2104</link>
		<dc:creator>William B. Sanders</dc:creator>
		<pubDate>Sun, 29 Jan 2012 19:21:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=6359#comment-2104</guid>
		<description>Hi Hayesmaker,

Yeah, the OneNav class doesn't do much for speeding things up. (I think I said as much.) The final designation does come into play at compile time, but like static objects, the CPU does not have to spend resources at run time determining the exact functions to call. So, indirectly, it saves CPU resources that would otherwise have to be expended at run time.

Kindest regards,
Bill</description>
		<content:encoded><![CDATA[<p>Hi Hayesmaker,</p>
<p>Yeah, the OneNav class doesn&#8217;t do much for speeding things up. (I think I said as much.) The final designation does come into play at compile time, but like static objects, the CPU does not have to spend resources at run time determining the exact functions to call. So, indirectly, it saves CPU resources that would otherwise have to be expended at run time.</p>
<p>Kindest regards,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on ActionScript 3.0 Single Class Event Handler by hayesmaker</title>
		<link>http://www.as3dp.com/2012/01/actionscript-3-0-single-class-event-handler/#comment-2102</link>
		<dc:creator>hayesmaker</dc:creator>
		<pubDate>Sun, 29 Jan 2012 11:08:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=6359#comment-2102</guid>
		<description>marking methods/classes final doesn't speed up runtime code execution.. so this isn't really a good speed tweak... and neither is the OneNav class.</description>
		<content:encoded><![CDATA[<p>marking methods/classes final doesn&#8217;t speed up runtime code execution.. so this isn&#8217;t really a good speed tweak&#8230; and neither is the OneNav class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on ActionScript 3.0 TouchEvent: Guaranteed Mobile Speedup by William B. Sanders</title>
		<link>http://www.as3dp.com/2012/01/actionscript-3-0-touchevent-guaranteed-mobile-speedup/#comment-2060</link>
		<dc:creator>William B. Sanders</dc:creator>
		<pubDate>Sat, 21 Jan 2012 09:17:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=6400#comment-2060</guid>
		<description>Hi HB,

I had noticed the Size properties. It is clear that Adobe considers MouseEvent to be faster for the reasons noted in the snippet from their docs (above.) However, in testing the responses using SimpleButton objects using the little app in this article, it was clear that TouchEvent worked better--it was more responsive and didn't get stuck. What did you find in testing it on a mobile device?

Thanks,
Bill</description>
		<content:encoded><![CDATA[<p>Hi HB,</p>
<p>I had noticed the Size properties. It is clear that Adobe considers MouseEvent to be faster for the reasons noted in the snippet from their docs (above.) However, in testing the responses using SimpleButton objects using the little app in this article, it was clear that TouchEvent worked better&#8211;it was more responsive and didn&#8217;t get stuck. What did you find in testing it on a mobile device?</p>
<p>Thanks,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on ActionScript 3.0 TouchEvent: Guaranteed Mobile Speedup by HB</title>
		<link>http://www.as3dp.com/2012/01/actionscript-3-0-touchevent-guaranteed-mobile-speedup/#comment-2057</link>
		<dc:creator>HB</dc:creator>
		<pubDate>Fri, 20 Jan 2012 13:35:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=6400#comment-2057</guid>
		<description>Looking at the documentation, TouchEvent indeed has a sizeX and sizeY properties that indicate the contact area, so my theory may be indeed right.

Also, there is a thing I didn't mention, but already assumed on my first reply, if my thought is indeed true, it would also explain why even using raw touch events needs more resources than plain mouse events. Having a single hot spot means there is no denying in which object on the screen you clicked, however, having an area means you must process that area, check all the objects it intersects with, and choose which one should receive the events (if not all of them do).</description>
		<content:encoded><![CDATA[<p>Looking at the documentation, TouchEvent indeed has a sizeX and sizeY properties that indicate the contact area, so my theory may be indeed right.</p>
<p>Also, there is a thing I didn&#8217;t mention, but already assumed on my first reply, if my thought is indeed true, it would also explain why even using raw touch events needs more resources than plain mouse events. Having a single hot spot means there is no denying in which object on the screen you clicked, however, having an area means you must process that area, check all the objects it intersects with, and choose which one should receive the events (if not all of them do).</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on ActionScript 3.0 TouchEvent: Guaranteed Mobile Speedup by William B. Sanders</title>
		<link>http://www.as3dp.com/2012/01/actionscript-3-0-touchevent-guaranteed-mobile-speedup/#comment-2056</link>
		<dc:creator>William B. Sanders</dc:creator>
		<pubDate>Fri, 20 Jan 2012 12:56:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=6400#comment-2056</guid>
		<description>HB,

This is especially true if you have 'fat fingers' like I do!

Cheers,
Bill</description>
		<content:encoded><![CDATA[<p>HB,</p>
<p>This is especially true if you have &#8216;fat fingers&#8217; like I do!</p>
<p>Cheers,<br />
Bill</p>
]]></content:encoded>
	</item>
</channel>
</rss>

