<?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>Flash Moments &#187; Suggestion</title>
	<atom:link href="http://flashmoments.novelastudios.com/tag/suggestion/feed/" rel="self" type="application/rss+xml" />
	<link>http://flashmoments.novelastudios.com</link>
	<description>ActionScript, Flash, and Flex</description>
	<lastBuildDate>Wed, 01 Dec 2010 02:59:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Process</title>
		<link>http://flashmoments.novelastudios.com/programming-practice/process/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://flashmoments.novelastudios.com/programming-practice/process/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 03:27:20 +0000</pubDate>
		<dc:creator>johntimothybailey</dc:creator>
				<category><![CDATA[Programming Practice]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Suggestion]]></category>

		<guid isPermaLink="false">http://flashmoments.novelastudios.com/?p=163</guid>
		<description><![CDATA[Process is like any philosophy: You have one even if you say you don&#8217;t care about it or think it causes more weight to consider it. In the case of not caring, process is more likely to be one of a disaster and stress similar to any philosophy that has no care and consideration &#8220;If stand [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"></div><p>Process is like any philosophy: You have one even if you say you don&#8217;t care about it or think it causes more weight to consider it.</p>
<div id="_mcePaste">In the case of not caring, process is more likely to <strong><em>be</em></strong> one of a disaster and stress similar to any philosophy that has no care and consideration</div>
<div id="_mcePaste">&#8220;If stand for nothing, you fall [ON] anything&#8221;</div>
<img src="http://flashmoments.novelastudios.com/?ak_action=api_record_view&id=163&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://flashmoments.novelastudios.com/programming-practice/process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing Algorithms &#8211; Creational Patterns</title>
		<link>http://flashmoments.novelastudios.com/architectural-pattern/parsing-algorithms-creational-patterns/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://flashmoments.novelastudios.com/architectural-pattern/parsing-algorithms-creational-patterns/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 18:57:56 +0000</pubDate>
		<dc:creator>johntimothybailey</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Architectural Pattern]]></category>
		<category><![CDATA[Programming Architecture]]></category>
		<category><![CDATA[Programming Practice]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Recommendations]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[Suggestion]]></category>

		<guid isPermaLink="false">http://flashmoments.novelastudios.com/?p=85</guid>
		<description><![CDATA[This is as much a recommendation as a rant, so pardon me while I do both Situation Open-source project or foundational classes for use within your organization that contains methods for parsing data. Background Often, I&#8217;ve run into issues where I am using an open-source library (public or private) and I need to add extra [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"></div><p><em><span style="color: #888888;">This is as much a recommendation as a rant, so pardon me while I do both <img src='http://flashmoments.novelastudios.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></em></p>
<p><strong>Situation<br />
</strong>Open-source project or foundational classes for use within your organization that contains methods for parsing data.</p>
<p><strong>Background<br />
</strong>Often, I&#8217;ve run into issues where I am using an open-source library (public or private) and I need to add extra logic to a creational algorithm(s) and cannot or cannot easily do so. This is what has sparked me to write this post, because I am increasingly seeing these types of issues.</p>
<p><strong>Recommendation<br />
</strong>When creating algorithms that create objects from other objects (eg models and serialization) , please use offload the logic to accessible and easily modifiable methods. In Design Pattern terms, I&#8217;m requesting and ranting that the Factory Method Pattern, Strategy Pattern, or something similar be used. This only compounds in importance when there are several objects created in a single method!  &lt;&#8211; That right there is arguably bad practice in general for large projects.</p>
<p><strong>Example<br />
<span style="font-weight: normal;"><em><span style="color: #808080;">NOTE</span></em></span><span style="font-weight: normal;"><em><span style="color: #808080;">: Showing a simple example seems to not show the problem, but I&#8217;ll try. For a better example, please refer to &#8220;Real-Life Example&#8221; below.</span></em></span></strong></p>
<p><strong> </strong></p>
<p><strong>Mapping XML properties to models within a project.</strong></p>
<pre lang="Actionscript">protected updateList():void
{
var header:Header = new Header;
header.title = _xml.header.@title;
header.lang = _xml.header.@lang;
header.colors = _xml.header.colors.toArray();

var body:Body = _body;
var child:XML;
for (var i:Number = 0; i &lt; _xml.body.item.length(); ++i)
{
child = _xml.body.item[i];
body.getItemAt(i).text = child.@text;
}
}</pre>
<p><strong><span style="font-weight: normal;"><br />
</span></strong></p>
<p><strong>Real-Life Example<br />
<em><span style="color: #333333;">NOTE:</span></em><span style="font-weight: normal;"> I do not mean to pick on or criticize the fine work done by the peeps working on the <a title="OpenVideoPlayer Project" href="openvideoplayer.sourceforge.net/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">OpenVideoPlayer Project</a> and MUST EMPHASIZE that the project is very useful and saves time. This merely serves as an easy example to show. Moreover, I&#8217;ve written my fair share of problematic code along these lines too.</span></strong></p>
<p><strong> </strong></p>
<ul>
<li><span style="font-weight: normal;"><a href="https://sourceforge.net/tracker/?func=detail&amp;aid=2977117&amp;group_id=243060&amp;atid=1121331">https://sourceforge.net/tracker/?func=detail&amp;aid=2977117&amp;group_id=243060&amp;atid=1121331</a></span></li>
</ul>
<img src="http://flashmoments.novelastudios.com/?ak_action=api_record_view&id=85&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://flashmoments.novelastudios.com/architectural-pattern/parsing-algorithms-creational-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Invoking Constructors</title>
		<link>http://flashmoments.novelastudios.com/architectural-pattern/invoking-constructors/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://flashmoments.novelastudios.com/architectural-pattern/invoking-constructors/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 18:04:08 +0000</pubDate>
		<dc:creator>johntimothybailey</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Architectural Pattern]]></category>
		<category><![CDATA[Programming Practice]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Suggestion]]></category>

		<guid isPermaLink="false">http://flashmoments.novelastudios.com/?p=38</guid>
		<description><![CDATA[RJ Regenold and I were discussing last night how we both strongly believe constructors should have extremely limited algorithms that simply invoke protected methods. For instance, PureMVC&#8217;s Facade initializes the instance in the constructor package org.puremvc.as3.multicore.patterns.facade { import org.puremvc.as3.multicore.core.*; import org.puremvc.as3.multicore.interfaces.*; import org.puremvc.as3.multicore.patterns.observer.*; public function Facade( key:String ) { if (instanceMap[ key ] != null) [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"></div><p><a href="http://blog.binarylionstudios.com/" target="_self">RJ Regenold</a> and I were discussing last night how we both strongly believe constructors should have extremely limited algorithms that simply invoke protected methods.</p>
<p>For instance, PureMVC&#8217;s Facade initializes the instance in the constructor</p>
<pre lang="Actionscript">package org.puremvc.as3.multicore.patterns.facade
{
	import org.puremvc.as3.multicore.core.*;
	import org.puremvc.as3.multicore.interfaces.*;
	import org.puremvc.as3.multicore.patterns.observer.*;

	public function Facade( key:String )
        {
	     if (instanceMap[ key ] != null) throw Error(MULTITON_MSG);
	     initializeNotifier( key );
	     instanceMap[ multitonKey ] = this;
	     initializeFacade();
	}
}
</pre>
<pre lang="Actionscript">package org.puremvc.as3.multicore.patterns.facade
{
	import org.puremvc.as3.multicore.core.*;
	import org.puremvc.as3.multicore.interfaces.*;
	import org.puremvc.as3.multicore.patterns.observer.*;

	public function Facade( key:String )
        {
	     if (instanceMap[ key ] != null) throw Error(MULTITON_MSG);
	     initializeNotifier( key );
	     initializeInstance();
	     initializeFacade();
	}

        protected function initializeInstance():void
        {
             instanceMap[ multitonKey ] = this;
        }
}
</pre>
<p>I would even argue that the Error checking / validation takes place in an init of some kind as well.</p>
<p>Another example is as follows<br />
Instead of doing,</p>
<pre lang="Actionscript">package
{
	import flash.display.Sprite;

	public class ViewUI extends Sprite
	{
		public function ViewUI()
		{
			super();
			width = 100;
			height = 200;
		}
	}
}
</pre>
<p>Do this</p>
<pre lang="Actionscript">package
{
	import flash.display.Sprite;

	public class ViewUI extends Sprite
	{
		public function ViewUI()
		{
			super();
			init();
		}

		protected function init():void
		{
			width = 100;
			height = 200;
		}
	}
}
</pre>
<p>This practice becomes increasingly important in open-source projects. Moreover, this example may be limited but consider more complex constructors that you&#8217;ve seen or written yourself. The construction process should be divided into segments when possible.</p>
<p>UPDATE ( 01.13.10 ): <a href="http://www.as3dp.com/2010/01/06/class-constructor-function-should-do-no-real-work-getting-agile-part-i/#more-2322">Bill Sanders recently posted a good article about this exact topic</a>!</p>
<img src="http://flashmoments.novelastudios.com/?ak_action=api_record_view&id=38&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://flashmoments.novelastudios.com/architectural-pattern/invoking-constructors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

