<?xml version="1.0" encoding="UTF-8"?>
<rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Gareth Townsend</title>
	
	<link>http://blog.garethtownsend.info</link>
	<description />
	<lastBuildDate>Tue, 04 Aug 2009 05:16:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/garethtownsendinfo" /><feedburner:info uri="garethtownsendinfo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Refactoring an Objective-C Method</title>
		<link>http://feedproxy.google.com/~r/garethtownsendinfo/~3/xi7hMPCwqUI/</link>
		<comments>http://blog.garethtownsend.info/2009/08/refactoring-an-objective-c-method/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 05:10:52 +0000</pubDate>
		<dc:creator>Gareth Townsend</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://blog.garethtownsend.info/?p=31</guid>
		<description><![CDATA[Sometimes you stumble across code that makes you think &#8220;WTF?&#8221;. Recently I discovered this Objective-C method in an iPhone project. I&#8217;ve renamed the method names and variables to protect the innocent.

This method is called when a user taps a button inside a table cell. The purpose of the method is to find the table cell [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you stumble across code that makes you think &#8220;WTF?&#8221;. Recently I discovered this Objective-C method in an iPhone project. I&#8217;ve renamed the method names and variables to protect the innocent.</p>
<p><script src="http://gist.github.com/161037.js"></script></p>
<p>This method is called when a user taps a button inside a table cell. The purpose of the method is to find the table cell that the button belongs to, and then call <code>didSelectRowAtIndexPath</code> on that table cell.</p>
<p>Disregarding the fact that this methods purpose makes <code>didSelectRowAtIndexPath</code> one very bloated method, there are a few other improvements we can make to it.</p>
<p>First, this method uses a C-style for loop. Objective-C 2.0 supports <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocFastEnumeration.html">fast enumeration</a>. Fast enumeration is faster, looks better, and throws an exception if you attempt to modify the collection while it is being enumerated.</p>
<p><script src="http://gist.github.com/161038.js"></script></p>
<p>Because <code>NSArray</code> has a well defined order, and enumeration proceeds in that order, we can simply count the index.</p>
<p>We now have more lines of code than the original, but the intent is somewhat clearer. The implementation of this method however, still relies on a string comparison to find the correct table cell, which is not ideal.</p>
<p>Using our knowledge of the view hierarchy we can re-implement this method to forgo enumeration altogether.</p>
<p><script src="http://gist.github.com/161031.js"></script></p>
<p>Knowing that our button is inside a table cell we can ask it for its superview. Once we have the table cell, we can ask for its indexPath. We can then call didSelectRowAtIndexPath directly using the indexPath.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=xi7hMPCwqUI:9BXroEwTJBI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=xi7hMPCwqUI:9BXroEwTJBI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=xi7hMPCwqUI:9BXroEwTJBI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=xi7hMPCwqUI:9BXroEwTJBI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?i=xi7hMPCwqUI:9BXroEwTJBI:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/garethtownsendinfo/~4/xi7hMPCwqUI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.garethtownsend.info/2009/08/refactoring-an-objective-c-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.garethtownsend.info/2009/08/refactoring-an-objective-c-method/</feedburner:origLink></item>
		<item>
		<title>Much Ado About Todo</title>
		<link>http://feedproxy.google.com/~r/garethtownsendinfo/~3/wRkgBBIu9Co/</link>
		<comments>http://blog.garethtownsend.info/2008/04/much-ado-about-todo/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 10:18:33 +0000</pubDate>
		<dc:creator>Gareth Townsend</dc:creator>
				<category><![CDATA[Code Quality]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://blog.garethtownsend.info/?p=5</guid>
		<description><![CDATA[How many times have you come across a comment block in a piece of code like this?:
# TODO &#8211; Make this work properly for all cases.
At some point in time this comment made sense. Someone, somewhere had every intention of fixing this and removing the comment.
It&#8217;s quite possible that someone was you, but you don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>How many times have you come across a comment block in a piece of code like this?:</p>
<blockquote><p># TODO &#8211; Make this work properly for all cases.</p></blockquote>
<p>At some point in time this comment made sense. Someone, somewhere had every intention of fixing this and removing the comment.</p>
<p>It&#8217;s quite possible that someone was you, but you don&#8217;t remember anymore.</p>
<h2>todos are irrelevant</h2>
<p>todos live in no-mans land. Stuck in a time warp for all eternity. Don&#8217;t kid yourself, you&#8217;re never going to re-visit a todo. They&#8217;re irrelevant.</p>
<p>They fly under the radar because they have no visibility. Out of sight, out of mind. If you&#8217;re not working on the code with the todo, then you don&#8217;t know it&#8217;s there, and you don&#8217;t care.</p>
<p>Other than doing a project wide search, you&#8217;re never going to find them all. Even if you do, you&#8217;re not going to understand the meaning of them all.</p>
<p>They&#8217;re irrelevant.</p>
<h2>making todos relevant again</h2>
<p>What&#8217;s the point of a todo list if nobody knows about it?</p>
<p>Take control of your todos and enshrine them in code that everyone sees every day. Write them into your test suite as pending tests.</p>
<p>Failing tests are bad. Passing tests are good. Pending tests are just plain annoying.</p>
<p>They clearly indicate that something hasn&#8217;t been finished properly. They&#8217;re visible every time you run your test suite. This means they annoy everyone until they&#8217;re fixed.</p>
<p>They define todos better than any other mechanism at your disposal.</p>
<h2>Sprinkle in a touch of guilt</h2>
<p>While a quick flick through <em>svn blame</em> will find the culprit, it&#8217;s not visible and it means work on your behalf.</p>
<p>Sprinkle in a touch of guilt by mandating all pending tests be created with the Authors name and todays date in the pending message.</p>
<p>That&#8217;ll ensure they don&#8217;t hang around like a bad smell for too long.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=wRkgBBIu9Co:GGI2honZsCE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=wRkgBBIu9Co:GGI2honZsCE:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=wRkgBBIu9Co:GGI2honZsCE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=wRkgBBIu9Co:GGI2honZsCE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?i=wRkgBBIu9Co:GGI2honZsCE:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/garethtownsendinfo/~4/wRkgBBIu9Co" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.garethtownsend.info/2008/04/much-ado-about-todo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.garethtownsend.info/2008/04/much-ado-about-todo/</feedburner:origLink></item>
		<item>
		<title>Short Stories Are Better Stories</title>
		<link>http://feedproxy.google.com/~r/garethtownsendinfo/~3/1kMdt6cbZoI/</link>
		<comments>http://blog.garethtownsend.info/2008/04/short-stories-are-better-stories/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 10:22:12 +0000</pubDate>
		<dc:creator>Gareth Townsend</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://blog.garethtownsend.info/?p=15</guid>
		<description><![CDATA[Any first year computer science student should be able to explain the divide and conquer, why it is important, and when to use it.
But how many developers apply it to their software engineering practices?
Stories
Agile developers work with the concept of stories. Essentially these are short explanations of what someone should be able to do with [...]]]></description>
			<content:encoded><![CDATA[<p>Any first year computer science student should be able to explain the <a href="http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm">divide and conquer</a>, why it is important, and when to use it.</p>
<p>But how many developers apply it to their software engineering practices?</p>
<h2>Stories</h2>
<p>Agile developers work with the concept of stories. Essentially these are short explanations of what someone should be able to do with the software once the story is implemented.</p>
<blockquote><p>A user should be able to manage their account.</p></blockquote>
<p>This story is vague, open ended and typical of client feature requests.</p>
<p>Before estimating this story, you&#8217;re going to need to get some fine grained detail into it. After talking with your client you might end up with the following:</p>
<blockquote><p>Managing their account consists of changing their name, updating their contact details, changing their profile picture, resetting their password and swapping between username/password and open-id for authentication.</p></blockquote>
<p>Now you have enough information to estimate this story, you know what the client means by <em>&#8220;manage their account&#8221;.</em></p>
<p>You might come up with an estimate of say 100 points.</p>
<p>This example is contrived but if every story your client sends you follows this same process you&#8217;re heading straight for a world of pain.</p>
<h2>The Effect of Large Stories on Iterations</h2>
<p>So you start work on your iteration with 10 large stories with your team and half way through you&#8217;re looking at the number of stories you&#8217;ve sent to your client for testing.</p>
<p>That number is zero and you&#8217;re starting to feel a bit stressed out. It&#8217;s ok though because by the end of the day 5 stories have moved into the testing phase.</p>
<p>You move on to the rest of the stories in the iteration and your client gets started testing the stories you&#8217;ve completed. Some of them pass and others get sent back because something is not quite right.</p>
<p>The cumulative effect of multiple large stories is an exponential story completeness graph.</p>
<p><img src="http://chart.apis.google.com/chart?chs=320x320&amp;chd=t:0,2,4,8,16,32,64,128&amp;cht=lc&amp;chtt=Story%20Completeness%20is%20Exponential" alt="Story Completeness is Exponential" /></p>
<h2>The Effect of Large Stories on Developers</h2>
<p>Working on the same story for a long period of time is painful. As a developer you feel like you&#8217;re climbing a mountain that just keeps getting bigger.</p>
<p>You&#8217;re not sure where the top is, and sometimes you think you&#8217;ve reached it, but as it turns out you&#8217;ve forgotten something and you&#8217;re not quite at the top.</p>
<p>The effect on the team is that everyone goes through this same journey every iteration.</p>
<p>Your client experiences the same in reverse. They sit around waiting to climb the mountain, and they wait, and then bang, they&#8217;re expected to be half way up the mountain almost instantly.</p>
<h2>Divide and Conquer for Happiness</h2>
<p>Large stories can often be broken down into smaller stories. In fact you already did this when estimating your stories. But you finished one step before you should have.</p>
<p>You should have split the original story into multiple smaller ones:</p>
<blockquote><p>A user should be able to change their name.</p></blockquote>
<blockquote><p>A user should be able to change their contact details.</p></blockquote>
<blockquote><p>A user should be able to change their profile picture.</p></blockquote>
<blockquote><p>A user should be able to change their password.</p></blockquote>
<blockquote><p>A user should be able to switch between username/password and openid for authentication.</p></blockquote>
<p>Each one of these stories is smaller, has easier to meet acceptance criteria and will be finished earlier.</p>
<p>Your client will love you because they don&#8217;t spend half their time sitting around and waiting for stories to test.</p>
<p>The developers in your team will love you because instead of climbing one massive mountain, they are climbing 5 mounds.</p>
<p>Everyone feels like they are constantly moving forwards through the iteration.</p>
<p>The story completeness graph moves from being exponential to linear.</p>
<p><img src="http://chart.apis.google.com/chart?chs=320x320&amp;chd=t:0,128&amp;cht=lc&amp;chtt=Story%20Completeness%20is%20Linear" alt="Story Completeness is Linear" /></p>
<p>That&#8217;s a much more positive graph to have hanging on your office wall.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=1kMdt6cbZoI:9JB3Cop73kg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=1kMdt6cbZoI:9JB3Cop73kg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=1kMdt6cbZoI:9JB3Cop73kg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/garethtownsendinfo?a=1kMdt6cbZoI:9JB3Cop73kg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/garethtownsendinfo?i=1kMdt6cbZoI:9JB3Cop73kg:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/garethtownsendinfo/~4/1kMdt6cbZoI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.garethtownsend.info/2008/04/short-stories-are-better-stories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.garethtownsend.info/2008/04/short-stories-are-better-stories/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 1.869 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-08-30 19:28:18 --><!-- Compression = gzip -->
