<?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>Eamonn Faherty &#187; development</title>
	<atom:link href="http://blog.eamonnfaherty.co.uk/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.eamonnfaherty.co.uk</link>
	<description>technology enthusiast, public speaker and technical director</description>
	<lastBuildDate>Mon, 26 Jul 2010 23:33:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>DJango in a (pea)nutshell</title>
		<link>http://blog.eamonnfaherty.co.uk/2010/07/26/django-in-a-peanutshell/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2010/07/26/django-in-a-peanutshell/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 23:31:40 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=313</guid>
		<description><![CDATA[DJango is an open source MVC (or MTV) Web CMS written in Python, HTML, JS and CSS. It uses a urls file to interpret the incoming request, separating out the params from the action, eg /customer/1/delete would be interpreted as delete customer 1. The urls file links the request to a view function. This view [...]


Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/09/08/social-networking/' rel='bookmark' title='Permanent Link: Social Networking'>Social Networking</a> <small>I am really interested in getting into the social networking...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><a href="www.djangoproject.com">DJango</a> is an open source MVC  (or <a href="http://docs.djangoproject.com/en/dev/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names">MTV</a>) Web CMS written in <a href="http://www.python.org/">Python</a>, HTML, JS and CSS.</p>
<p>It uses a urls file to interpret the incoming request, separating out the params from the action, eg /customer/1/delete would be interpreted as delete customer 1.</p>
<p>The urls file links the request to a view function.  This view function uses the model objects to modify the values in the database and then passes them onto a template.  This template then displays them!</p>
<p>The model objects are stored in a database and are defined using <a href="http://www.python.org/">python</a>.  There is not really any need to know sql. Although, I would always suggest knowing it!!!</p>
<p>That is it, really! There are loads of great features that I will cover soon!</p>
<p>I am doing my first commercial project in <a href="http://www.djangoproject.com/">DJango</a> and it is going well! I will  post on it once it goes live!</p>


<p>Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/09/08/social-networking/' rel='bookmark' title='Permanent Link: Social Networking'>Social Networking</a> <small>I am really interested in getting into the social networking...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2010/07/26/django-in-a-peanutshell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jiglibflash First Experiences</title>
		<link>http://blog.eamonnfaherty.co.uk/2010/07/22/jiglibflash-first-experiences/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2010/07/22/jiglibflash-first-experiences/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 19:56:53 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[jiglibflash]]></category>
		<category><![CDATA[papervision]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=299</guid>
		<description><![CDATA[I have been playing around with jiglibflash. It is a rigid body physics engine. I have been looking at example projects like this. I am working on a secret project at work and I thought it would be good to share what I have learned. I want to point out that I had no 3d [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I have been playing around with <a href="http://www.jiglibflash.com/blog/">jiglibflash</a>.  It is a rigid body physics engine.  I have been looking at example projects like <a href="http://www.everydayflash.com/blog/index.php/2009/04/23/jiglibflash-3d-physics/">this</a>.  </p>
<p>I am working on a secret project at work and I thought it would be good to share what I have learned.  I want to point out that I had no 3d experience before I started this!  So you should be able to do this too! </p>
<p>I have been using <a href="http://blog.papervision3d.org/">papervision</a> to render a texture map.  It takes a black and white jpeg which marks shallower and higher areas on a terrain.  <a href="http://blog.papervision3d.org/">Papervision</a> converts this into a 3d terrain, mountains and ditches.  I also have a car which is loaded from a dae file.  <a href="http://blog.papervision3d.org/">Papervision</a> loads this file and renders it.  I am then using Jiglibflash to create JBoxes, JSpheres and others.  These &#8216;J&#8217; shapes are used for the collision detection.  You can even have a <a href="http://blog.papervision3d.org/">Papervision</a> sphere inside a JBox and the physics engine will treat it as a box.  It does all the collision detections for you.  It takes care of friction and gravity.  You can apply forces to the shapes.  It is really straight forward handling simple shapes.  The next stage of my project is to start describing complex shapes using these J shapes.  It is going to be tough!!! </p>
<p>Using these libraries has been great! It has been a bit of a pain as Jiglibflash uses <a href="http://blog.papervision3d.org/">Papervision</a> (you can also choose to use <a href="http://www.away3d.com">Away3D</a>) and you need to ensure you use working sets of <a href="http://www.jiglibflash.com/blog/">Jiglibflash</a> and <a href="http://blog.papervision3d.org/">Papervision</a>.  A lot of the examples use strange combinations of versions so beware!</p>
<p>I will post the other stuff I discover as I discover it!</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2010/07/22/jiglibflash-first-experiences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blog updates</title>
		<link>http://blog.eamonnfaherty.co.uk/2010/03/15/blog-updates/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2010/03/15/blog-updates/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 13:13:55 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=283</guid>
		<description><![CDATA[My blog is now on the Amazon cloud! I have signed up to AWS and am hosting my own sites on my own box (running Gentoo). I have also enabled a social networking plugin for wordpress that allows you to login using your google account. I will adding support for twitter and facebook soon! Related [...]


Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/09/08/social-networking/' rel='bookmark' title='Permanent Link: Social Networking'>Social Networking</a> <small>I am really interested in getting into the social networking...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2010/01/27/google-services-what-a-gem/' rel='bookmark' title='Permanent Link: [Google Services] What a gem!'>[Google Services] What a gem!</a> <small>I have been using Google Apps for over a year...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>My blog is now on the Amazon cloud!  I have signed up to AWS and am hosting my own sites on my own box (running Gentoo).</p>
<p>I have also enabled a social networking plugin for wordpress that allows you to login using your google account.  I will adding support for twitter and facebook soon!</p>


<p>Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/09/08/social-networking/' rel='bookmark' title='Permanent Link: Social Networking'>Social Networking</a> <small>I am really interested in getting into the social networking...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2010/01/27/google-services-what-a-gem/' rel='bookmark' title='Permanent Link: [Google Services] What a gem!'>[Google Services] What a gem!</a> <small>I have been using Google Apps for over a year...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2010/03/15/blog-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript3 TDD: A Little More Terminology</title>
		<link>http://blog.eamonnfaherty.co.uk/2009/11/22/actionscript3-tdd-a-little-more-terminology/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2009/11/22/actionscript3-tdd-a-little-more-terminology/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 00:00:19 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[flashtdd]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=260</guid>
		<description><![CDATA[This is the last blog post I plan to make about the terminology around TDD. There will be real life examples from now on. I have previously discussed the terms collaborators, subject under test (SUT) and test doubles. Here, I am going to describe the three types of test doubles you can use. The Real [...]


Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-tdd-introduction-terminology/' rel='bookmark' title='Permanent Link: Actionscript3 TDD: Introduction / Terminology'>Actionscript3 TDD: Introduction / Terminology</a> <small>I have been posting about design patterns recently and I...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-design-patternsfactory-method/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:Factory Method'>Actionscript3 Design Patterns:Factory Method</a> <small>Background Reading The creation method pattern The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Singleton'>Actionscript3 Design Patterns:The Singleton</a> <small>Background Reading None The Problem? You want to ensure you...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This is the last blog post I plan to make about the terminology around TDD. There will be real life examples from now on.<br />
I have previously discussed the terms collaborators, subject under test (SUT) and test doubles.  Here, I am going to describe the three types of test doubles you can use.</p>
<p><strong>The Real Thing</strong><br />
If you have a simple collaborator which only really stores and retrieves values, like a model, then is it worth replacing it for testing purposes?  I personally think as long as this collaborator is unit tested then it is okay.  Once there is some logic in the collaborator, some mutator methods, then I think you must refactor your unit tests and use a proper test double.</p>
<p><strong>Stubs</strong><br />
Stubs are replacements for collaborators with pre-programmed responses for requests and fields that store inputs:</p>
<pre class="brush:as3">public function get username():String {
    return "eamonn";
}
public function set username(username:String):void {
    _usernameSetDuringTest = username;
}</pre>
<p>The first method does two important things.  It makes your code deterministic.  Your collaborator will always return &#8220;eamonn&#8221; as a username. It also means that the only complicated thing is your subject under test.  Both of these things are very important for unit testing code.<br />
The second method stores the input sent to the object.  The field _usernameSetDuringTest can be queried later to find out if the test should pass or fail.</p>
<p><strong>Mocks</strong><br />
Mocks are objects setup to expect interactions.  When you use a mock you define which methods on it should be called and which parameters it expects.  You run your test code and then you verify that the mock has been interacted with in the way you thought it should have been.</p>
<p><strong>My Thoughts</strong><br />
From my experience I have found mocks to be very frustrating.  Unit tests that use mocks are more tightly coupled to the production code and this makes refactoring harder.<br />
If I rename the method in the example above I have the following changes:<br />
<em>If using a mock, I would change the name of the method in the real collaborator, the test double and in the unit test as it would be listed as a method that should be called.</em><br />
or<br />
<em>If using a stub, I would change the name of the method in the real collaborator and in the test double</em><br />
If I am using FDT and these two classes implement the same interface I can use the refactor -> rename method tool within FDT.  This handles the rename when using a stub.  It cannot currently handle the change if I had used a mock.<br />
This might seem like a lazy reason to use a stub over a mock but you will have to consider when you will be making this change.  It will probably be a very high priority bug fix needed a year after you wrote the code and you will probably want to get it resolved ASAP.  There are many other reasons to use stubs over mocks but I think you should make that decision with your team or for yourself.  <a href="http://martinfowler.com/articles/mocksArentStubs.html">Here</a> is a really good article on the differences between mocks and stubs.  It also spiders onto other good articles on other testing approaches. It is definitely worth checking out if you have the time.</p>


<p>Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-tdd-introduction-terminology/' rel='bookmark' title='Permanent Link: Actionscript3 TDD: Introduction / Terminology'>Actionscript3 TDD: Introduction / Terminology</a> <small>I have been posting about design patterns recently and I...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-design-patternsfactory-method/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:Factory Method'>Actionscript3 Design Patterns:Factory Method</a> <small>Background Reading The creation method pattern The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Singleton'>Actionscript3 Design Patterns:The Singleton</a> <small>Background Reading None The Problem? You want to ensure you...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2009/11/22/actionscript3-tdd-a-little-more-terminology/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript3 TDD: Introduction / Terminology</title>
		<link>http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-tdd-introduction-terminology/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-tdd-introduction-terminology/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 22:37:40 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=254</guid>
		<description><![CDATA[I have been posting about design patterns recently and I am realizing that it would be useful to post about Test Driven Development too. As a gentle introduction I am going to go through some of the vocabulary. Test Driven Development is the process; Red, Green, Refactor. That is the easy way to remember it. [...]


Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-design-patternsfactory-method/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:Factory Method'>Actionscript3 Design Patterns:Factory Method</a> <small>Background Reading The creation method pattern The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Multiton'>Actionscript3 Design Patterns:The Multiton</a> <small>Background Reading Read about the singleton The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Singleton'>Actionscript3 Design Patterns:The Singleton</a> <small>Background Reading None The Problem? You want to ensure you...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I have been posting about design patterns recently and I am realizing that it would be useful to post about <a href="http://en.wikipedia.org/wiki/Test-driven_development">Test Driven Development</a> too. </p>
<p>As a gentle introduction I am going to go through some of the vocabulary.</p>
<p>Test Driven Development is the process; Red, Green, Refactor.  That is the easy way to remember it.  Below is your workflow:</p>
<p>1) Write a unit test.  A unit test is a method that tests another method.  The test calls the method that you are testing and verifies that the response is as expected.  Your unit test should always use the same inputs and should always expect the same response.  The class containing the method you are testing is called your subject under test (SUT).</p>
<pre class="brush:as3">
public function testAddingTwoNumbers():void {
    var result:int = sut.add(2,3);
    assertEquals(5, result);
}
</pre>
<p>2) Run your unit test.  It should fail.  This feels kind of silly but this is the best (easiest) way to check that the test is being run. This is the RED stage.</p>
<p>3) Write some source code that makes the test pass.  This should simple literal values.  Run your test and it should pass. This is the GREEN stage. This also feels silly but it proves your test passes before you add the complex logic in there.</p>
<pre class="brush:as3">
public function add(valueOne:int, valueTwo:int):int {
    return 5;
}
</pre>
<p>4) This is now where you refactor.  You take steps to make your design better.  It is up to you how far to take the refactoring.  In this example I would change the method to the following:</p>
<pre class="brush:as3">
public function add(valueOne:int, valueTwo:int):int {
    return valueOne + valueTwo;
}
</pre>
<p>The example above was trivial.  The add method does not use any other objects.  If it did the correct name for those objects would be a collaborator.  When you are TDD&#8217;ing you should replace collaborators with simple objects that return simple values.  These are referred to as test doubles, after the term stunt double.  You can use patterns such as the IOC pattern and Factory patterns to make it easier to replace collaborators with test doubles.  That is coming in post 2!</p>


<p>Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-design-patternsfactory-method/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:Factory Method'>Actionscript3 Design Patterns:Factory Method</a> <small>Background Reading The creation method pattern The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Multiton'>Actionscript3 Design Patterns:The Multiton</a> <small>Background Reading Read about the singleton The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Singleton'>Actionscript3 Design Patterns:The Singleton</a> <small>Background Reading None The Problem? You want to ensure you...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-tdd-introduction-terminology/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript3 Design Patterns:Factory Method</title>
		<link>http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-design-patternsfactory-method/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-design-patternsfactory-method/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 21:55:46 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[design patterns]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=250</guid>
		<description><![CDATA[Background Reading The creation method pattern The Problem? You want to use objects that are created else where and are of a set type but the implementations may vary. Examples? SocketManager, or any thing that needs to be replace during unit testing. How? The constructor of my complex object: public class CharacterFactory { public static [...]


Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/11/actionscript3-design-patternscreation-method/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:Creation Method'>Actionscript3 Design Patterns:Creation Method</a> <small>Background Reading The factory method pattern The Problem? You have...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Multiton'>Actionscript3 Design Patterns:The Multiton</a> <small>Background Reading Read about the singleton The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Singleton'>Actionscript3 Design Patterns:The Singleton</a> <small>Background Reading None The Problem? You want to ensure you...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Background Reading<br />
The creation method pattern</p>
<p>The Problem?<br />
You want to use objects that are created else where and are of a set type but the implementations may vary. </p>
<p>Examples?<br />
SocketManager, or any thing that needs to be replace during unit testing.</p>
<p>How?<br />
The constructor of my complex object:</p>
<pre class=‚Äùbrush:as3‚Äù>
public class CharacterFactory {

	public static var factory : NonPlayerCharacterFactory;

	public static function getAPlayer() : IPlayer {
		return factory.getAButton();
	}
}
</pre>
<p>The using of the creation method:</p>
<pre class=‚Äùbrush:as3‚Äù>
var player:IPlayer = CharacterFactory. getAPlayer();
</pre>
<p>Why is it good?<br />
‚Ä¢	It is easy to understand; it is a simple pattern that needs little extra code.  It builds on the singleton pattern, which is well known.<br />
‚Ä¢	You can get objects without knowing how they are created or where they come from.<br />
‚Ä¢	You can share objects without the users of the factory knowing the objects are shared.</p>
<p>Why is it bad?<br />
‚Ä¢	It is confusing to read code where objects are not being created directly.<br />
‚Ä¢	Debugging is hard, as you have to know what was in the factory when you used it in order to know what object you have.</p>
<p>Further Reading<br />
Read about the IOC pattern. </p>
<p>More<br />
Factories are great! They allow you to define scope for your application.  This means that you can set a testing scope when you are running unit tests.  The involves setting the factories used in your factory to a test factory which provides test doubles.  Changing the scope of the factories outside of your application means that you test your code without making any special changes.</p>


<p>Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/11/actionscript3-design-patternscreation-method/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:Creation Method'>Actionscript3 Design Patterns:Creation Method</a> <small>Background Reading The factory method pattern The Problem? You have...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Multiton'>Actionscript3 Design Patterns:The Multiton</a> <small>Background Reading Read about the singleton The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Singleton'>Actionscript3 Design Patterns:The Singleton</a> <small>Background Reading None The Problem? You want to ensure you...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-design-patternsfactory-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript3 Design Patterns:Creation Method</title>
		<link>http://blog.eamonnfaherty.co.uk/2009/11/11/actionscript3-design-patternscreation-method/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2009/11/11/actionscript3-design-patternscreation-method/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 20:17:35 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[creation method]]></category>
		<category><![CDATA[design patterns]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=242</guid>
		<description><![CDATA[Background Reading The factory method pattern The Problem? You have a complex object, which has a lot of arguments in its constructor or you always want to construct the object using different sets of parameters. Examples? Socket Manager How? The constructor of my complex object: public function ComplicatedButton(colour:uint, mouseOverColour:uint, mouseOutColour:uint) { _mouseOverColour = mouseOverColour; _mouseOutColour [...]


Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Singleton'>Actionscript3 Design Patterns:The Singleton</a> <small>Background Reading None The Problem? You want to ensure you...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Multiton'>Actionscript3 Design Patterns:The Multiton</a> <small>Background Reading Read about the singleton The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/10/31/design-patterns-for-actionscript-3/' rel='bookmark' title='Permanent Link: Design Patterns for Actionscript 3'>Design Patterns for Actionscript 3</a> <small>I recently did my first public talk! It was at...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><strong>Background Reading</strong><br />
The factory method pattern</p>
<p><strong>The Problem?</strong><br />
You have a complex object, which has a lot of arguments in its constructor or you always want to construct the object using different sets of parameters.</p>
<p><strong>Examples?</strong><br />
Socket Manager</p>
<p><strong>How?</strong><br />
The constructor of my complex object:</p>
<pre class=‚Äùbrush:as3‚Äù>
public function ComplicatedButton(colour:uint, mouseOverColour:uint, mouseOutColour:uint) {
	_mouseOverColour = mouseOverColour;
	_mouseOutColour = mouseOutColour;
	setUpGraphics(colour);
addEventListeners();
}
</pre>
<p>The using of the creation method:</p>
<pre class=‚Äùbrush:as3‚Äù>
var redButton : ComplicatedButton = ComplicatedButton.getRedButton();
var blueButton : ComplicatedButton = ComplicatedButton.getBlueButton();
</pre>
<p><strong>Why is it good?</strong><br />
‚Ä¢	It is easy to understand; it is a simple pattern that needs little extra code.  It builds on the singleton pattern, which is well known.<br />
‚Ä¢	Anyone using one of the creation methods to create the object is guaranteed to have an object in an identical state as the other users of the method.<br />
‚Ä¢	Objects that complicated or a lot of constructor parameters can be simplified.</p>
<p><strong>Why is it bad?</strong><br />
‚Ä¢	The class now has two responsibilities, the main purpose of the class plus the instantiation of its instances.<br />
‚Ä¢	The class can often grow in size as the creators in declared inside the class.  This makes the class harder to read for a developer.</p>
<p><strong>Further Reading</strong><br />
Read about the factory patterns. </p>
<p><strong>More</strong><br />
Creation methods are a great first move towards using factories.  Their concept is easy to grasp and doesn‚Äôt require much extra code.  The class can grow quite big, quite quickly but it is up to you to spot when the acceptable size has been passed for you to put your refactoring hat on.  I would use them when I have a graphical component that accepts integer colours as parameters or when I have components that need a lot of initial set up.  In the example above I have colours specified as integers.  To ensure that all of the buttons considered to be red or blue are the same shades of red or blue I protect users of my ComplicatedButton by adding creation methods with the colours hard coded.  Once I have more than one group of setups I would refactor, replacing the creation method with a factory method.</p>


<p>Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Singleton'>Actionscript3 Design Patterns:The Singleton</a> <small>Background Reading None The Problem? You want to ensure you...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Multiton'>Actionscript3 Design Patterns:The Multiton</a> <small>Background Reading Read about the singleton The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/10/31/design-patterns-for-actionscript-3/' rel='bookmark' title='Permanent Link: Design Patterns for Actionscript 3'>Design Patterns for Actionscript 3</a> <small>I recently did my first public talk! It was at...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2009/11/11/actionscript3-design-patternscreation-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript3 Design Patterns:The Multiton</title>
		<link>http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 22:27:37 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[multiton]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=238</guid>
		<description><![CDATA[Background Reading Read about the singleton The Problem? You want to have multiple instances of a singleton and want global access to them all. This may be because the objects use groups of resources, such as different groups of sounds, or because the objects need a lot of configuration, such as currency converters, or need [...]


Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Singleton'>Actionscript3 Design Patterns:The Singleton</a> <small>Background Reading None The Problem? You want to ensure you...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/10/31/design-patterns-for-actionscript-3/' rel='bookmark' title='Permanent Link: Design Patterns for Actionscript 3'>Design Patterns for Actionscript 3</a> <small>I recently did my first public talk! It was at...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><strong>Background Reading</strong><br />
Read about the singleton</p>
<p><strong>The Problem?</strong><br />
You want to have multiple instances of a singleton and want global access to them all.  This may be because the objects use groups of resources, such as different groups of sounds, or because the objects need a lot of configuration, such as currency converters, or need global access, an event dispatcher.</p>
<p><strong>Examples?</strong><br />
Currency converter, sound controller, global event dispatcher</p>
<p><strong>How?</strong><br />
The Multiton:</p>
<pre class="brush:as3">
public class SocketManagerMultiton {
	private static var _instaces : Dictionary;
	public static const CHAT : String = "CHAT";
	public static const WEATHER : String = "WEATHER";

	public static function getInstace(instance:String) : SocketManagerMultiton {
	ensureInstanceExists(instance);
		return _instaces[instance];
	}

private static function ensureInstanceExists(instance:String) : void {
		if (_instaces == null) {
			_instaces = new Dictionary();
		}
		if (_instaces[instance] == null) {
			_instaces[instance] = new SocketManagerMultiton();
		}
	}

	public function send(message : String) : void {
	}
}
</pre>
<p><strong>Example Use:</strong></p>
<pre class="brush:as3">
var chatSocket : SocketManagerMultiton = SocketManagerMultiton.getInstace(SocketManagerMultiton.CHAT);
chatSocket.send("hello world");

var weatherSocket : SocketManagerMultiton = SocketManagerMultiton.getInstace(SocketManagerMultiton.WEATHER);
weatherSocket.send("HOW_IS_THE_WEATHER");
</pre>
<p><strong>Why is it good?</strong><br />
‚Ä¢	It is easy to understand; it is a simple pattern that needs little extra code.  It builds on the singleton pattern, which is well known.<br />
‚Ä¢	See singleton pattern for other good points.</p>
<p><strong>Why is it bad?</strong><br />
‚Ä¢	It tightly couples the classes that use the multiton to the fact that they are using a multiton.<br />
‚Ä¢	See singleton pattern for other bad points.</p>
<p><strong>Further Reading</strong><br />
Read about the factory and inversion of control patterns. </p>
<p><strong>More</strong><br />
Multitons are a way of grouping Singletons.  They share the benefits and carry the problems that Singletons have.  They are good for classes that use a lot of resources such as socket connections or classes that cache things.  They do make code harder to refactor and very difficult to unit test but if follow the suggestions I made in the Singleton post then you can limit your pain, a bit anyway!  If you are going to use a multiton make sure you use String constants as I did above.  It is easy to make typing mistakes when using String literals.  Also the constants can be meaningful, as they are in my example.</p>


<p>Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Singleton'>Actionscript3 Design Patterns:The Singleton</a> <small>Background Reading None The Problem? You want to ensure you...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/10/31/design-patterns-for-actionscript-3/' rel='bookmark' title='Permanent Link: Design Patterns for Actionscript 3'>Design Patterns for Actionscript 3</a> <small>I recently did my first public talk! It was at...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript3 Design Patterns:The Singleton</title>
		<link>http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 00:25:33 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=234</guid>
		<description><![CDATA[Background Reading None The Problem? You want to ensure you have only a single instance of an object and want global access to it. This may be because the object uses a resource, such as sounds, or because the object needs a lot of configuration, such as a currency formatter, or needs global access, an [...]


Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Multiton'>Actionscript3 Design Patterns:The Multiton</a> <small>Background Reading Read about the singleton The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-design-patternsfactory-method/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:Factory Method'>Actionscript3 Design Patterns:Factory Method</a> <small>Background Reading The creation method pattern The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/11/actionscript3-design-patternscreation-method/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:Creation Method'>Actionscript3 Design Patterns:Creation Method</a> <small>Background Reading The factory method pattern The Problem? You have...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><strong>Background Reading</strong><br />
None</p>
<p><strong>The Problem?</strong><br />
You want to ensure you have only a single instance of an object and want global access to it.  This may be because the object uses a resource, such as sounds,  or because the object needs a lot of configuration, such as a currency formatter, or needs global access, an event dispatcher.</p>
<p><strong>Examples?</strong><br />
Currency formatter, sound controller, global event dispatcher</p>
<p><strong>How?</strong><br />
The Singleton:</p>
<pre class="brush:as3">package singletonpattern {

	/**
	 * @author eamonn faherty
	 */
	public class SocketManagerSingleton {
		private static var _instace : SocketManagerSingleton;

		public static function getInstace() : SocketManagerSingleton {
			ensureInstanceExists();
			return _instace;
		}

		private static function ensureInstanceExists() : void {
			if (_instace == null) {
				_instace = new SocketManagerSingleton();
			}
		}

		public function send(message : String) : void {
		}
	}
}</pre>
<p>Example Usage:</p>
<pre class="brush:as3">
package singletonpattern {
	import common.Example;		

	/**
	 * @author eamonn faherty
	 */
	public class SingletonPatternExample extends Example {

		public function SingletonPatternExample() {
			var socket : SocketManagerSingleton = SocketManagerSingleton.getInstace();

			socket.send("Hello world");
		}
	}
}</pre>
<p><strong>Why is it good?</strong><br />
‚Ä¢	It works well; if you use an instance protector then you can be sure that only a single instance will exist.<br />
‚Ä¢	It is well understood; it is widely used in the actionscript world.<br />
‚Ä¢	It is easy to understand; it is a simple pattern that needs little extra code.<br />
‚Ä¢	It is easy to implement; actionscript allows us to check the caller of a method and allows us to use private classes.</p>
<p><strong>Why is it bad?</strong><br />
‚Ä¢	It tightly couples the classes that use the singleton to the fact that they are using a singleton.<br />
‚Ä¢	It is not possible to extend the singleton class if you wanted to add functionality.<br />
‚Ä¢	You cannot use your singleton class again; you cannot extend it or reuse it with composition.<br />
‚Ä¢	If you are unit testing a class that uses a singleton you need to add some code to your singleton to make testing possible.</p>
<p><strong>Further Reading</strong><br />
Read about the factory and inversion of control patterns.</p>


<p>Related posts:<ol><li><a href='http://blog.eamonnfaherty.co.uk/2009/11/10/actionscript3-design-patternsthe-multiton/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:The Multiton'>Actionscript3 Design Patterns:The Multiton</a> <small>Background Reading Read about the singleton The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/17/actionscript3-design-patternsfactory-method/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:Factory Method'>Actionscript3 Design Patterns:Factory Method</a> <small>Background Reading The creation method pattern The Problem? You want...</small></li>
<li><a href='http://blog.eamonnfaherty.co.uk/2009/11/11/actionscript3-design-patternscreation-method/' rel='bookmark' title='Permanent Link: Actionscript3 Design Patterns:Creation Method'>Actionscript3 Design Patterns:Creation Method</a> <small>Background Reading The factory method pattern The Problem? You have...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2009/11/09/actionscript3-design-patternsthe-singleton/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Design Patterns for Actionscript 3</title>
		<link>http://blog.eamonnfaherty.co.uk/2009/10/31/design-patterns-for-actionscript-3/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2009/10/31/design-patterns-for-actionscript-3/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 23:34:27 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[lfpug]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=227</guid>
		<description><![CDATA[I recently did my first public talk! It was at LFPUG (London Flash Platform UserGroup). Here are the details I think it went really well. I had some very kind feedback via email and twitter and also on the night in person! A few people have requested that I upload the examples I used and [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I recently did my first public talk! It was at LFPUG (London Flash Platform UserGroup).</p>
<p><a href="http://www.lfpug.com/29th-october-2009-29102009/">Here are the details</a></p>
<p>I think it went really well. I had some very kind feedback via email and twitter and also on the night in person!</p>
<p>A few people have requested that I upload the examples I used and the slides so here they are.</p>
<p>Over the next few weeks I am going to be posting example patterns with more information, in more depth than I did on the night.</p>
<p>If you want me to cover a pattern please post a comment with the pattern name and I will bump it up in the list.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2009/10/31/design-patterns-for-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
