<?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>simonrichardson.info</title>
	<atom:link href="http://www.simonrichardson.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simonrichardson.info</link>
	<description></description>
	<lastBuildDate>Tue, 17 Aug 2010 19:57:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Activities &amp; Services</title>
		<link>http://www.simonrichardson.info/2010/08/17/activities-services/</link>
		<comments>http://www.simonrichardson.info/2010/08/17/activities-services/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 19:57:42 +0000</pubDate>
		<dc:creator>Simon Richardson</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">http://www.simonrichardson.info/?p=87</guid>
		<description><![CDATA[As you might of guessed with some of the new blog posts, I&#8217;m doing some work with Android. I&#8217;ve also been doing some experimental work with the new AIR 2.5 for Android devices, I will talk about this more in the following posts, back to Activities and Services. One thing I&#8217;ve been wanting to do [...]]]></description>
			<content:encoded><![CDATA[<p>As you might of guessed with some of the new blog posts, I&#8217;m doing some work with Android. I&#8217;ve also been doing some experimental work with the new AIR 2.5 for Android devices, I will talk about this more in the following posts, back to Activities and Services.</p>
<p>One thing I&#8217;ve been wanting to do is have the ability to a SocketServer running in the background and allow messaging between what&#8217;s passed to the socket and then to the activity. I&#8217;m mainly thinking about debugging device connectivity to back end servers, updating views on the fly without the need to recompile.</p>
<p>There doesn&#8217;t actually seem like there isn&#8217;t much documentation about getting the service to talk back to the activity once it&#8217;s been created. Then I hit the goldmine, which explained it all. I actually found it in the Android documentation (<a href="http://developer.android.com/reference/android/app/Service.html">Service</a>) but as usual it&#8217;s all over the place. Essentially you need to look at the LocalService documentation, but what it boils down to is creating a Binder class and pass that back. The Binder feels like a closer which you just call on when the Service has been connected. What I also did was implement the Observable pattern, that way when the activity retrieves the service using the getService() (see example) you can then just pass observable data back and forth. It&#8217;s extremely fast once the service is up and running, which is ideal for this and what I&#8217;m going to be using it for.</p>
<p>I&#8217;ll post later on what I&#8217;m actually doing with this, but lets just say it involves the AIR SDK.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrichardson.info/2010/08/17/activities-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Certified ScrumMaster</title>
		<link>http://www.simonrichardson.info/2010/08/11/certified-scrummaster/</link>
		<comments>http://www.simonrichardson.info/2010/08/11/certified-scrummaster/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 20:05:45 +0000</pubDate>
		<dc:creator>Simon Richardson</dc:creator>
				<category><![CDATA[Scrum]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[scrum]]></category>
		<guid isPermaLink="false">http://www.simonrichardson.info/?p=84</guid>
		<description><![CDATA[I&#8217;m now an official Certified ScrumMaster! I&#8217;ve been putting the test off for sometime now, no idea why? But I got reminded today (that&#8217;s that friend again!) that if I don&#8217;t take the test soon, the time to take it would run out. So I kicked myself into gear and completed it. I wished I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m now an official Certified ScrumMaster! I&#8217;ve been putting the test off for sometime now, no idea why? But I got reminded today (that&#8217;s that friend again!) that if I don&#8217;t take the test soon, the time to take it would run out. So I kicked myself into gear and completed it. I wished I done it sooner, as it would have been completely fresh in the head. The scrum teacher, Colin Bird must have done a good job because I remembered pretty much everything and didn&#8217;t take 45 minutes as suggested. </p>
<p>Special note, thank&#8217;s to <a href="http://www.ustwo.co.uk">ustwo&trade;</a> for the training.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrichardson.info/2010/08/11/certified-scrummaster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android: Reuse everything.</title>
		<link>http://www.simonrichardson.info/2010/08/11/android-reuse-everything/</link>
		<comments>http://www.simonrichardson.info/2010/08/11/android-reuse-everything/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 15:57:32 +0000</pubDate>
		<dc:creator>Simon Richardson</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linkedin]]></category>
		<guid isPermaLink="false">http://www.simonrichardson.info/?p=70</guid>
		<description><![CDATA[As you might have known (previous post), I&#8217;ve been tasked to go and learn Android. I&#8217;ve mentioned in the last post that I&#8217;m not a huge fan of the xml layout capabilities, but there isn&#8217;t much I can do with that, you&#8217;ve got what&#8217;ve got. Android ListView So I ran into another problem with ListViews [...]]]></description>
			<content:encoded><![CDATA[<p>As you might have known (<a href="http://www.simonrichardson.info/2010/08/10/android-first-glance/">previous post</a>), I&#8217;ve been tasked to go and learn Android. I&#8217;ve mentioned in the last post that I&#8217;m not a huge fan of the xml layout capabilities, but there isn&#8217;t much I can do with that, you&#8217;ve got what&#8217;ve got. </p>
<p><strong>Android ListView</strong></p>
<p>So I ran into another problem with ListViews this week, I couldn&#8217;t for the life of me get a customised list to run fast. The list in question is like a regular contact list, headers for each letter of the alphabet (where required) and contact rows for the users. Each contact row has a background image, different contact images and various text tweaks. </p>
<p>I didn&#8217;t realise at the time, but the getView method which you override to supply the new customised rows has an argument that you should not overlook (<em>I did!</em>). The key to performance lies in the second argument, this passes you a view from the list which isn&#8217;t displayed in the screen any more. The ListView is rather clever here and rather than creating new items for every single item in the list, it ask&#8217;s you the question &#8220;can you reuse this view?&#8221;. It&#8217;s now up to you to decide if you can reuse the view or not?</p>
<p>The simple answer: You should always reuse the view even if the views are different. In my case the headers are different from the contact rows, because you don&#8217;t know the order of the what the ListView is going to pass back the views. Without going down the path of forward look ups (expensive?). In my case I could sometimes get a header and what I really wanted was a contact row, so I would throw that view away. That row would then be left for the GC and I would have to create a new one. Memory allocation on any device is very expensive, be careful how you do it and where you do it! </p>
<p>I worked out for one contact user row we can reuse a lot of the views the more contact rows there is, which normally goes against the grain. The more rows there are the more optimised the code becomes. Unfortunately if you have not enough contacts in the ListView you end up running the worst case, not enough contacts and you run slow and just to many contacts to run slow as well. This isn&#8217;t good enough!</p>
<p><strong>Object pooling</strong></p>
<p>At first I thought about creating a pool of rows for both header and contacts. So the creation of the rows are up front, reusing the rows depending on the content required. Except this won&#8217;t work because the ListView already manages this and you&#8217;ll end up getting into a mess, where you&#8217;re doing some pooling and the ListView is doing it&#8217;s own pooling. Avoid this at all costs, the next solution is a lot simpler.</p>
<p><strong>Abstract your views</strong></p>
<p>So I was discussing this with a friend of mine and he said I was doing this the wrong way (cheers!). What I should be doing is finding similarities of my layouts and abstracting them into a view. Adding backgrounds and just setting the visibilities to &#8220;gone&#8221;. Effectively hiding them, when needing them setting them back to &#8220;visible&#8221; in code. This way, when ever getView passes back a view I can use it! It&#8217;s better to add images to a ImageView by code than create a new row. </p>
<p>Inflation of code is expensive, creation of lots of new layouts, views are expensive. It&#8217;s far better to create one item than many, it may seem obvious saying it now, but behind all the method calls and other logic it&#8217;s hard to see the trees from the wood.</p>
<p><strong>Reuse your views!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrichardson.info/2010/08/11/android-reuse-everything/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android: First glance</title>
		<link>http://www.simonrichardson.info/2010/08/10/android-first-glance/</link>
		<comments>http://www.simonrichardson.info/2010/08/10/android-first-glance/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 15:56:41 +0000</pubDate>
		<dc:creator>Simon Richardson</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linkedin]]></category>
		<guid isPermaLink="false">http://www.simonrichardson.info/?p=64</guid>
		<description><![CDATA[Recently I&#8217;ve been tasked to learn Android whilst at Great Fridays, I&#8217;ve been keeping a close eye on Android for sometime and jumped ship from iPhone to Android device about 2 months ago. Let me say there are some very rough edges to the operating system, which need to be addressed or users will simply [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been tasked to learn Android whilst at <a href="http://www.greatfridays.com">Great Fridays</a>, I&#8217;ve been keeping a close eye on Android for sometime and jumped ship from iPhone to Android device about 2 months ago. Let me say there are some very rough edges to the operating system, which need to be addressed or users will simply pick up the next latest thing. </p>
<p>So what is it like developing Android? To be honest, I&#8217;m finding it quite slow going, there is a lot of documentation for the platform, which is great. What isn&#8217;t great is the lack of sandboxed examples, the API demos don&#8217;t count as this is a mess beyond believe! These should be split up in to micro applications that just show one thing and not everything. I&#8217;m from a AS3 background, where if something isn&#8217;t working I know where to extend and implement and how to implement. This has taken years of experience, knowing where to mount my overriding behaviour. The problem this is a different language, a different code framework, so being able to customise layouts and components is rather tiresome and difficult. I&#8217;m learning from scratch, I&#8217;m a small fish and a very big ocean!</p>
<p>At first I thought the xml setup of views and the like would be amazing, but I&#8217;m going off it already. I&#8217;m still going to keep cracking at it, as I&#8217;m sure it&#8217;s the best way, but I feel I can knock something out which is more flexible in code, that might just be me? &#8211; I also feel the same way about mxml! I even understand why you should do this, I&#8217;ve even created a layout manager in xml for my own projects and I&#8217;ve made a XUL parser years ago for a university project. The problem is I think the layout management in Android is wrong, it&#8217;s not flexible enough, it&#8217;s too restrictive. I would have preferred making it more like a fluid layout system and just attaching objects to rows, columns. I&#8217;ve been told about layout_weight recently, which is something I&#8217;ve completely overlooked and that give me the satisfaction I&#8217;ve been looking for, it&#8217;s something to look at though.</p>
<p>One thing I do like though is the component set (minus the layout views), they seem powerful and thought through, something to definitely build off. Just a pity they&#8217;re not supported by good feature set around them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrichardson.info/2010/08/10/android-first-glance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Unit tests (Part 3)</title>
		<link>http://www.simonrichardson.info/2010/08/06/unit-tests-part-3/</link>
		<comments>http://www.simonrichardson.info/2010/08/06/unit-tests-part-3/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 08:55:33 +0000</pubDate>
		<dc:creator>Simon Richardson</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[flexunit]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[unittest]]></category>
		<guid isPermaLink="false">http://www.simonrichardson.info/?p=44</guid>
		<description><![CDATA[I was meant to finish this article ages ago, sorry for the late response. I was going to talk about my experiences when using Flex Unit and ASUnit. Both have there strong and weak points and each can be easily broken down to nth degree, but I&#8217;ll just say it extremely simply. If you want [...]]]></description>
			<content:encoded><![CDATA[<p>I was meant to finish this article ages ago, sorry for the late response. I was going to talk about my experiences when using Flex Unit and ASUnit. Both have there strong and weak points and each can be easily broken down to nth degree, but I&#8217;ll just say it extremely simply. If you want to use a CIServer then from my experience then use Flex Unit, it&#8217;s more tightly integrated with various servers. I&#8217;m not saying that ASUnit doesn&#8217;t integrate with a CIServer, I&#8217;m saying that Flex Unit currently does it a lot better. Flex Unit will tackle both pure ActionScript and Flex, so should be able to tackle anything you can throw at it. ASUnit will mainly tackle ActionScript, I&#8217;ve not tried it out with Flex, just because I&#8217;ve not had the time. Let me know if you have!</p>
<p>Also to note that if you like metadata with in your flash apps then Flex Unit will also be a benefit. I&#8217;m not a huge fan as I can&#8217;t use static naming for the strings within metadata and you have to be hugely careful about how you spell things, also I like the DRY principal where you write once! Failure of the language if you ask me. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrichardson.info/2010/08/06/unit-tests-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Language</title>
		<link>http://www.simonrichardson.info/2010/05/06/language/</link>
		<comments>http://www.simonrichardson.info/2010/05/06/language/#comments</comments>
		<pubDate>Thu, 06 May 2010 16:10:59 +0000</pubDate>
		<dc:creator>Simon Richardson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">http://www.simonrichardson.info/?p=58</guid>
		<description><![CDATA[Why has nobody made a new language on the AVM2 (other than haXe)? It&#8217;s a bold statement, but seriously why not? Someone could have implemented a functional type language similar to scala or dynamic language like groovy, which sits on the JVM? It does raise questions why nobody has thought about this before or have [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Why has nobody made a new language on the AVM2 (other than <a href="http://haxe.org">haXe</a>)?</p></blockquote>
<p>It&#8217;s a bold statement, but seriously why not?<br />
Someone could have implemented a functional type language similar to <a href="http://www.scala-lang.org/">scala</a> or dynamic language like <a href="http://groovy.codehaus.org/">groovy</a>, which sits on the JVM?</p>
<p>It does raise questions why nobody has thought about this before or have they and thought it was a complete waist of time. It surprises me that nobody else has joined haXe in the movement and attempted the same feat. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrichardson.info/2010/05/06/language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interruption</title>
		<link>http://www.simonrichardson.info/2010/05/06/interruption/</link>
		<comments>http://www.simonrichardson.info/2010/05/06/interruption/#comments</comments>
		<pubDate>Thu, 06 May 2010 15:59:55 +0000</pubDate>
		<dc:creator>Simon Richardson</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[HaXe]]></category>
		<category><![CDATA[HaXe-C++]]></category>
		<category><![CDATA[performance]]></category>
		<guid isPermaLink="false">http://www.simonrichardson.info/?p=51</guid>
		<description><![CDATA[I know I&#8217;ve supposed to have written about Unit testing (part 3), it&#8217;s in draft and needs amending, but in the mean time I&#8217;ve been thinking about compilers and languages. I&#8217;ve been reading the dragon book of late, because I&#8217;ve needed to implement a coding style verifier and micro optimiser (something which has been talked [...]]]></description>
			<content:encoded><![CDATA[<p>I know I&#8217;ve supposed to have written about Unit testing (part 3), it&#8217;s in draft and needs amending, but in the mean time I&#8217;ve been thinking about compilers and languages. I&#8217;ve been reading the <a href="http://en.wikipedia.org/wiki/Dragon_Book_(computer_science)">dragon book</a> of late, because I&#8217;ve needed to implement a coding style verifier and micro optimiser (something which has been talked about in length by developers). </p>
<p>One thing has struck me of late and that is; we do have really fast operational codes in the <a href="http://www.ncannasse.fr/blog/adobe_alchemy">language</a>, but other than <a href="http://haxe.org/">haXe</a> and <a href="http://labs.adobe.com/technologies/alchemy/">Adobe Alchemy</a> not much is taking advantage of it. You can of course try and use <a href="http://blog.joa-ebert.com/2009/08/05/turbodieselsportinjection/">TDSI</a> from <a href="http://blog.joa-ebert.com/">Joa Ebert</a>, but why should we have to optimise something after we&#8217;ve written it? This should be either standard from the language or the compiler.</p>
<p><strong>So what is this really about?</strong><br />
This is about wanting to code without thinking about optimising the basics, you don&#8217;t hear of C/C++/C#/Java developers talking about trying to squeeze every ounce of power from the language every time they code something. I&#8217;m not saying you shouldn&#8217;t optimise, what I am saying is that as a platform it always seems like we&#8217;re starting with a handicap.<br />
I want the fasting language for the platform and have all the features for the language. I really like method overloading from Java. I know the AVM2 doesn&#8217;t support it by default, but that doesn&#8217;t stop you from implementing in some way. A perfect example of this is type parameters (generics) of the Vector class, which I really like from Java and HaXe, but why is it not default on all objects. The compiler checks what your implementing and the aligns it to correct compound types. </p>
<p>Now why can&#8217;t a language do this for method overloading, by simply changing the method signature to something else at compile time.</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;color: #FCFFBA;"><span style="color: #339966; font-weight: bold;color: #8FB394;">function</span> <span style="color: #004993;">method</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000000; font-weight: bold;color: #CCC;">:</span><span style="color: #004993;">String</span><span style="color: #000000;color: #CCC;">&#41;</span> <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> <span style="color: #0033ff; font-weight: bold;color: #B83A24;">void</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #000000;color: #CCC;">&#125;</span>
<span style="color: #339966; font-weight: bold;color: #8FB394;">function</span> <span style="color: #004993;">method</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000000; font-weight: bold;color: #CCC;">:</span><span style="color: #004993;">String</span>, age<span style="color: #000000; font-weight: bold;color: #CCC;">:</span><span style="color: #004993;">int</span><span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000; font-weight: bold;color: #CCC;">:</span><span style="color: #0033ff; font-weight: bold;color: #B83A24;">void</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #000000;color: #CCC;">&#125;</span>
<span style="color: #004993;">method</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">'fred'</span><span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #004993;">method</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">'jim'</span>, <span style="color: #000000; font-weight:bold;color: #DDD;">24</span><span style="color: #000000;color: #CCC;">&#41;</span>;</pre></td></tr></table></div>
<p>This would be translated to the following:</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;color: #FCFFBA;"><span style="color: #339966; font-weight: bold;color: #8FB394;">function</span> method_StringVoid<span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000000; font-weight: bold;color: #CCC;">:</span><span style="color: #004993;">String</span><span style="color: #000000;color: #CCC;">&#41;</span> <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> <span style="color: #0033ff; font-weight: bold;color: #B83A24;">void</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #000000;color: #CCC;">&#125;</span>
<span style="color: #339966; font-weight: bold;color: #8FB394;">function</span> method_StringIntVoid<span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000000; font-weight: bold;color: #CCC;">:</span><span style="color: #004993;">String</span>, age<span style="color: #000000; font-weight: bold;color: #CCC;">:</span><span style="color: #004993;">int</span><span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000; font-weight: bold;color: #CCC;">:</span><span style="color: #0033ff; font-weight: bold;color: #B83A24;">void</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #000000;color: #CCC;">&#125;</span>
method_StringVoid<span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">'fred'</span><span style="color: #000000;color: #CCC;">&#41;</span>;
method_StringIntVoid<span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">'jim'</span>, <span style="color: #000000; font-weight:bold;color: #DDD;">24</span><span style="color: #000000;color: #CCC;">&#41;</span>;</pre></td></tr></table></div>
<p>The reason for the curious method signature is to enable something to call the method if it&#8217;s not directly know i.e. external swf file etc.</p>
<p>Also why is the fastest int, not used automatically? To use the fastest int, you have to delve into opcodes, which seems extraordinary as you&#8217;re actually saying to your developers &#8220;we do have this really fast player, but you&#8217;re not allowed to use it&#8221;. It would be great if a language just used the fastest int and not require the developer to jump into another language (C/C++/haXe).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrichardson.info/2010/05/06/interruption/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit tests (Part 2)</title>
		<link>http://www.simonrichardson.info/2010/04/25/unit-tests-part-2/</link>
		<comments>http://www.simonrichardson.info/2010/04/25/unit-tests-part-2/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 19:05:28 +0000</pubDate>
		<dc:creator>Simon Richardson</dc:creator>
				<category><![CDATA[Testing]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[unittesting]]></category>
		<guid isPermaLink="false">http://www.simonrichardson.info/?p=39</guid>
		<description><![CDATA[In part 1 I described the rationale behind why I personally think unit tests can help save you money and time when building software for your clients. Part 2 is what started as a google search, turned into a dive into the deep-end of CI. Continuous Integration (CI) CI is a trick subject either you [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.simonrichardson.info/2010/04/22/unit-tests-part-1/">part 1</a> I described the rationale behind why I personally think unit tests can help save you money and time when building software for your clients. Part 2 is what started as a google search, turned into a dive into the deep-end of CI.</p>
<p><strong>Continuous Integration (CI)</strong><br />
CI is a trick subject either you instantly get what it&#8217;s for or you don&#8217;t. I guess it&#8217;s a case of you&#8217;ll know when you need it. </p>
<p>So what is it? Well it&#8217;s a normally a server application that allows you to monitor your builds and allow you to track broken builds as well as the state of your unit tests that you&#8217;ve been writing. This becomes incredibly useful if you&#8217;re working with others (not limited too though, it&#8217;s also useful if you write alone). At any point in time you would be able to see what the main state of your software is at a very high level. A great side effect for me is that &#8211; I can point clients, developers and testers to one location and they can grab a build (known as an artifact in the CI world) for them to use. Everything is transparent, to you, your boss, your clients, everybody and this is the benefit. The more transparent you are the better expectations of the software people will have. It&#8217;s amazingly simple, hiding things away will come and bite you later on.</p>
<p>Which software?  I spent a only a few hours trying to find a CI application, because the way I see it is, try something first and if it doesn&#8217;t fit the bill, just migrate to the next thing. I ended up with <a href="http://cruisecontrol.sourceforge.net/">Cruise Control</a>, it&#8217;s definitely not the prettiest application in the world and it feels very disjointed from a UX point of view, but does the job well. I did originally want to use <a href="http://hudson-ci.org/">Hudson</a>, but it doesn&#8217;t support OS X. </p>
<p>Hardware? Ideally I would love to use <a href="http://www.ubuntu.com/">ubuntu</a> as the OS of choice, but could only get my hands on a old PowerPC G5 (with 6GB ram!!). This should be easily sufficient for running the builds.</p>
<p><strong>Getting started.</strong><br />
Because Cruise Control is a java application, it default runs on the <a href="http://jetty.codehaus.org/jetty/">Jetty</a> server. It&#8217;s a great server out of the box and needs almost no configuration to get the server running. The only one for me is hooking up to the <a href="http://logging.apache.org/log4j/1.2/">log4j</a> to something other than the console.</p>
<p>The next thing was setting up a project that was the &#8220;turnkey&#8221; example. This turned out to be a mixed experience&#8230; to set up a very basic example is extremely easy. The configuration file syntax is not to dissimilar to ant, which makes life extremely easy. I just pulled a branch (so I didn&#8217;t break anything from the master) from my git repository to the projects folder and hooked up my build file to the configuration file. I also utilised the clean to remove all the artifacts from the previous build so we always start with a clean build. That way if something goes wrong, it doesn&#8217;t affect the next build. I also used the configuration file to do a &#8220;git pull&#8221; at the bootstrap phase, so I didn&#8217;t have to do a pull manually.</p>
<p>That&#8217;s it, I had the simplest setup CI, the massive issue I had was getting logging to work for unit tests. There really needs to be more documentation about this as to me or new comers it feels like magic how it works.</p>
<p>So to all new people, you have to output all you&#8217;re log files to xml, it has to be in xml (you can do other file formats, but this is the easiest way) and it has to conform to junit xml format. I put my log files in the project and made a log folder where the logs could be dumped into when building. On clear command I would recreate the log folder. Then using the configuration tell CI where to look to find out if it was a successful build. This part took me half a day to figure out, it didn&#8217;t help when you have two programs called &#8220;cruisecontrol&#8221;, one being this and another being for ruby. I don&#8217;t know which came first, but one needs to change their name!</p>
<p><strong>Web interface</strong><br />
I&#8217;m not going to talk too much about this, but to be honest it feels horrible to use from a UX and graphical point of view. It needs someone to go through the design and just tie it together. It&#8217;s a real pity as there is so much information in the interface, but you really have to go looking. There is a lot of information about types of builds, failures and configurations it&#8217;s just not presented well. It could easily become amazing as it has all the right features, but just doesn&#8217;t compete.</p>
<p><strong>Conclusion</strong><br />
All in all, it wasn&#8217;t a bad experience, but it just feels like the whole thing is held together with magic &#8211; especially with the logging system for builds and unit tests. It&#8217;s hard to have 100% faith in something that you would like to do CI with. The great thing is that this could be easily sorted with some more documentation and some fixes to the configuration site.</p>
<p>Part 3 : ASUnit vs FlexUnit</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrichardson.info/2010/04/25/unit-tests-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Unit tests (Part 1)</title>
		<link>http://www.simonrichardson.info/2010/04/22/unit-tests-part-1/</link>
		<comments>http://www.simonrichardson.info/2010/04/22/unit-tests-part-1/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 16:47:24 +0000</pubDate>
		<dc:creator>Simon Richardson</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[unittest]]></category>
		<guid isPermaLink="false">http://www.simonrichardson.info/?p=32</guid>
		<description><![CDATA[I&#8217;ve been tasked recently to try and get a Continuous Integration (CI) server up and running. The reason for this piece of R&#038;D was because we had a scrum workshop and it became apparent that this could help us with our own frameworks. The interesting fact that was brought up from the workshop was; when [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been tasked recently to try and get a Continuous Integration (CI) server up and running. The reason for this piece of R&#038;D was because we had a scrum workshop and it became apparent that this could help us with our own frameworks. The interesting fact that was brought up from the workshop was; when developing software, you will spend most of the time maintaining the product after the first release. I&#8217;ve been on 3 major pieces of software in the last 2 years, each really exhaustive in the way of how much content we need to display with in very limited device setups. Every time we spend more time on maintenance than on developing the piece. When developing for devices there is even more of a watchful eye on the memory and cpu allocations, out of memory are frequent. It&#8217;s also important to note that users don&#8217;t follow the happy root that the UX people designed for, they will always find ways to &#8220;improve&#8221; it! I personally belief that software has a longer life cycle than a website and it&#8217;s this life cycle that we have to be careful for new bugs and regressions.</p>
<p>One possible way to help solve this would be to introduce testers, this is great, but keeping testers on the pay role constantly testing everything is very expensive. So if we as developers can help testers find an issue before testing software, they will thank-you (not forgetting your Finance guys and clients!). Testers don&#8217;t want to test buggy software because of some regression when happened to find it into your software somehow. So  if we could introduce steps in between developers coding the software and releasing it to testers then I&#8217;m all for that. </p>
<p>This is where Unit Tests come in. Now I&#8217;m not saying you can test everything 100% (UI is extremely hard!), but what I am saying is that you should be testing the places in your code that get hit hard and often. I&#8217;m sold, it makes complete sense, those that don&#8217;t see the benefits of unit testing in software are just making mistakes for themselves to pick up later on and it will cost you massively. And it&#8217;s not just cost, it&#8217;s time and as a developer do you really want to spend the next 6 months fixing simple mistakes that you accidentally made 8 months ago. </p>
<p>In my eyes, unit tests help produce high quality code because it reduces the errors that hit your users &#8211; it&#8217;s that simple!</p>
<p>Part 2: <a href="http://www.simonrichardson.info/2010/04/25/unit-tests-part-2/">How to setup CI</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrichardson.info/2010/04/22/unit-tests-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Casting Performance</title>
		<link>http://www.simonrichardson.info/2010/03/11/casting-performance/</link>
		<comments>http://www.simonrichardson.info/2010/03/11/casting-performance/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 21:08:19 +0000</pubDate>
		<dc:creator>Simon Richardson</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[flash]]></category>
		<guid isPermaLink="false">http://www.simonrichardson.info/?p=12</guid>
		<description><![CDATA[I was reading a couple of blog posts about performance recently with trying to bring some speed to my personal project, more about that in up and coming posts. One interesting fact that keeps rearing it&#8217;s head is that we should never cast[wiki], when coding. I find this statement a little hard to stomach. I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading a couple of blog posts about performance recently with trying to bring some speed to my personal project, more about that in up and coming posts. One interesting fact that keeps rearing it&#8217;s head is that we should never cast[wiki], when coding. I find this statement a little hard to stomach. I&#8217;ve been writing OOP for some years and find it hard to not cast! I try and reduce the amount of casting required by making sure I&#8217;m explicit as much as possible, but even so, you have to do it (unless some one can show me how to write a very complex project without it!).</p>
<p>So now we know we have to do it, what are the best ways to do it. I was running some tests last night and I was actually surprised that I didn&#8217;t know this, because it&#8217;s obvious.</p>
<p>I made a test which just loops through a for loop attempting to cast various items or the iterator. It&#8217;s fairly explanatory, just run the for loops multiple times until you get a big enough delta between beforeTime and the current time to make any sense.</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;color: #FCFFBA;">const NUM_ITERATIONS <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;color: #DDD;">1000000</span>;
<span style="color: #6699cc; font-weight: bold;color: #577A61;">var</span> i <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;color: #DDD;">0</span>;
<span style="color: #6699cc; font-weight: bold;color: #577A61;">var</span> beforeTime <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> <span style="color: #004993;">int</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;color: #577A61;">var</span> element <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> IElement = ElementFactory.create<span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
&nbsp;
beforeTime = <span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;color: #B83A24;">for</span><span style="color: #000000;color: #CCC;">&#40;</span>i=<span style="color: #000000; font-weight:bold;color: #DDD;">0</span>; i<span style="color: #000000; font-weight: bold;color: #CCC;">&lt;</span>= NUM_ITERATIONS; <span style="color: #000000; font-weight: bold;color: #CCC;">++</span>i<span style="color: #000000;color: #CCC;">&#41;</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #6699cc; font-weight: bold;color: #577A61;">var</span> item0 <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> Element = Element<span style="color: #000000;color: #CCC;">&#40;</span>element<span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #000000;color: #CCC;">&#125;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">&quot;<span style="">\t</span>Cast method (Class(instance)): &quot;</span> <span style="color: #000000; font-weight: bold;color: #CCC;">+</span> <span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000; font-weight: bold;color: #CCC;">-</span>beforeTime<span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
&nbsp;
beforeTime = <span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;color: #B83A24;">for</span><span style="color: #000000;color: #CCC;">&#40;</span>i=<span style="color: #000000; font-weight:bold;color: #DDD;">0</span>; i<span style="color: #000000; font-weight: bold;color: #CCC;">&lt;</span>= NUM_ITERATIONS; <span style="color: #000000; font-weight: bold;color: #CCC;">++</span>i<span style="color: #000000;color: #CCC;">&#41;</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #6699cc; font-weight: bold;color: #577A61;">var</span> item1 <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> Element = element <span style="color: #0033ff; font-weight: bold;color: #B83A24;">as</span> Element;
<span style="color: #000000;color: #CCC;">&#125;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">&quot;<span style="">\t</span>Cast method (instance as Class): &quot;</span> <span style="color: #000000; font-weight: bold;color: #CCC;">+</span> <span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000; font-weight: bold;color: #CCC;">-</span>beforeTime<span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
&nbsp;
beforeTime = <span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;color: #B83A24;">for</span><span style="color: #000000;color: #CCC;">&#40;</span>i=<span style="color: #000000; font-weight:bold;color: #DDD;">0</span>; i<span style="color: #000000; font-weight: bold;color: #CCC;">&lt;</span>= NUM_ITERATIONS; <span style="color: #000000; font-weight: bold;color: #CCC;">++</span>i<span style="color: #000000;color: #CCC;">&#41;</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #6699cc; font-weight: bold;color: #577A61;">var</span> item2 <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> <span style="color: #004993;">int</span> = <span style="color: #004993;">int</span><span style="color: #000000;color: #CCC;">&#40;</span>i<span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #000000;color: #CCC;">&#125;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">&quot;<span style="">\t</span>Cast method (int(instance)): &quot;</span> <span style="color: #000000; font-weight: bold;color: #CCC;">+</span> <span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000; font-weight: bold;color: #CCC;">-</span>beforeTime<span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
&nbsp;
beforeTime = <span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;color: #B83A24;">for</span><span style="color: #000000;color: #CCC;">&#40;</span>i=<span style="color: #000000; font-weight:bold;color: #DDD;">0</span>; i<span style="color: #000000; font-weight: bold;color: #CCC;">&lt;</span>= NUM_ITERATIONS; <span style="color: #000000; font-weight: bold;color: #CCC;">++</span>i<span style="color: #000000;color: #CCC;">&#41;</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #6699cc; font-weight: bold;color: #577A61;">var</span> item3 <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> <span style="color: #004993;">int</span> = i <span style="color: #0033ff; font-weight: bold;color: #B83A24;">as</span> <span style="color: #004993;">int</span>;
<span style="color: #000000;color: #CCC;">&#125;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">&quot;<span style="">\t</span>Cast method (instance as int): &quot;</span> <span style="color: #000000; font-weight: bold;color: #CCC;">+</span> <span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000; font-weight: bold;color: #CCC;">-</span>beforeTime<span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
&nbsp;
beforeTime = <span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;color: #B83A24;">for</span><span style="color: #000000;color: #CCC;">&#40;</span>i=<span style="color: #000000; font-weight:bold;color: #DDD;">0</span>; i<span style="color: #000000; font-weight: bold;color: #CCC;">&lt;</span>= NUM_ITERATIONS; <span style="color: #000000; font-weight: bold;color: #CCC;">++</span>i<span style="color: #000000;color: #CCC;">&#41;</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #6699cc; font-weight: bold;color: #577A61;">var</span> item4 <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> <span style="color: #004993;">String</span> = <span style="color: #004993;">String</span><span style="color: #000000;color: #CCC;">&#40;</span>i<span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #000000;color: #CCC;">&#125;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">&quot;<span style="">\t</span>Cast method (String(instance)): &quot;</span> <span style="color: #000000; font-weight: bold;color: #CCC;">+</span> <span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000; font-weight: bold;color: #CCC;">-</span>beforeTime<span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
&nbsp;
beforeTime = <span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;color: #B83A24;">for</span><span style="color: #000000;color: #CCC;">&#40;</span>i=<span style="color: #000000; font-weight:bold;color: #DDD;">0</span>; i<span style="color: #000000; font-weight: bold;color: #CCC;">&lt;</span>= NUM_ITERATIONS; <span style="color: #000000; font-weight: bold;color: #CCC;">++</span>i<span style="color: #000000;color: #CCC;">&#41;</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #6699cc; font-weight: bold;color: #577A61;">var</span> item5 <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> <span style="color: #004993;">String</span> = i <span style="color: #0033ff; font-weight: bold;color: #B83A24;">as</span> <span style="color: #004993;">String</span>;
<span style="color: #000000;color: #CCC;">&#125;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">&quot;<span style="">\t</span>Cast method (instance as String): &quot;</span> <span style="color: #000000; font-weight: bold;color: #CCC;">+</span> <span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000; font-weight: bold;color: #CCC;">-</span>beforeTime<span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
&nbsp;
beforeTime = <span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;color: #B83A24;">for</span><span style="color: #000000;color: #CCC;">&#40;</span>i=<span style="color: #000000; font-weight:bold;color: #DDD;">0</span>; i<span style="color: #000000; font-weight: bold;color: #CCC;">&lt;</span>= NUM_ITERATIONS; <span style="color: #000000; font-weight: bold;color: #CCC;">++</span>i<span style="color: #000000;color: #CCC;">&#41;</span>
<span style="color: #000000;color: #CCC;">&#123;</span>
<span style="color: #6699cc; font-weight: bold;color: #577A61;">var</span> item6 <span style="color: #000000; font-weight: bold;color: #CCC;">:</span> <span style="color: #004993;">String</span> = i.<span style="color: #004993;">toString</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span>;
<span style="color: #000000;color: #CCC;">&#125;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #990000;color: #666666;">&quot;<span style="">\t</span>Cast method (instance.toString()): &quot;</span> <span style="color: #000000; font-weight: bold;color: #CCC;">+</span> <span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;color: #CCC;">&#40;</span><span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000; font-weight: bold;color: #CCC;">-</span>beforeTime<span style="color: #000000;color: #CCC;">&#41;</span><span style="color: #000000;color: #CCC;">&#41;</span>;</pre></td></tr></table></div>
<p><strong>So the results:</strong></p>
<p>Cast method (Class(instance)): 6<br />
Cast method (instance as Class): 75<br />
Cast method (int(instance)): 3<br />
Cast method (instance as int): 61<br />
Cast method (String(instance)): 407<br />
Cast method (instance as String): 67<br />
Cast method (instance.toString()): 478</p>
<p><strong>So what does this mean?</strong></p>
<p>To keep it short. Don&#8217;t cast to another type, so don&#8217;t go from int to String, use &#8216;as&#8217;. Don&#8217;t use the toString() method for casting a int to a string, it&#8217;s very costly.</p>
<p>This is the important bit: Only if you know what the instance is it safe to do a cast and make sure you don&#8217;t use &#8216;as&#8217;. So if you know it&#8217;s an Element because of the IElement interface or because of a way to quickly test it (enum class which you define), then use type conversion.</p>
<p>Casting is expensive if you do it wrong, so make sure you do it correctly.</p>
<p><strong>Note:</strong><br />
I tested this with the latest Flash Player 10.1 b3, so this could all change. I&#8217;ve not tested with old Flash Players because I&#8217;ve got better things to do! Also test with the normal release and not the debugger, I can not emphasis that enough!</p>
<p><strong>Update:</strong><br />
This (i as String) would equal null, I should of checked this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrichardson.info/2010/03/11/casting-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
