<?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>David Laing's blog &#187; Code smells</title>
	<atom:link href="http://davidlaing.com/category/software-craftmanship/code-smells/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidlaing.com</link>
	<description>Craftmanship over crap</description>
	<lastBuildDate>Mon, 19 Jul 2010 00:39:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9-rare</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fitnesse Smell &#8211; Executable Requirements that look like Scripts</title>
		<link>http://davidlaing.com/2010/06/16/fitnesse-smell-executable-requirements-that-look-like-scripts/</link>
		<comments>http://davidlaing.com/2010/06/16/fitnesse-smell-executable-requirements-that-look-like-scripts/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 14:11:19 +0000</pubDate>
		<dc:creator>mrdavidlaing</dc:creator>
				<category><![CDATA[Code smells]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[acceptance tests]]></category>
		<category><![CDATA[codesmell]]></category>
		<category><![CDATA[fitnesse]]></category>

		<guid isPermaLink="false">http://davidlaing.com/?p=232</guid>
		<description><![CDATA[Gojko (who wrote the Fitnesse book) has this interesting discussion on what makes a good acceptance test in Fitnesse.
http://gojko.net/2010/06/16/anatomy-of-a-good-acceptance-test/
His point seems to be that Fitnesse is a good tool for documenting specifications, and continuously automating their validation.  When your Fitnesse tests become like &#8220;scripts&#8221; (which is how developers are trained to see the world), [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://gojko.net" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://gojko.net');">Gojko</a> (who wrote the <a href="http://gojko.net/2009/12/07/fitnesse-book-now-free-online/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://gojko.net/2009/12/07/fitnesse-book-now-free-online/');">Fitnesse book</a>) has this interesting discussion on what makes a good acceptance test in Fitnesse.</p>
<p><a href="http://gojko.net/2010/06/16/anatomy-of-a-good-acceptance-test/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://gojko.net/2010/06/16/anatomy-of-a-good-acceptance-test/');">http://gojko.net/2010/06/16/anatomy-of-a-good-acceptance-test/</a></p>
<p>His point seems to be that Fitnesse is a good tool for documenting specifications, and continuously automating their validation.  When your Fitnesse tests become like &#8220;scripts&#8221; (which is how developers are trained to see the world), then Fitnesse is a pretty crummy test execution environment (just use a unit test runner!)</p>
<p>Interesting that alternate tools &#8211; http://www.concordion.org, http://wiki.github.com/aslakhellesoy/cucumber/, http://www.specflow.org/ have arisen that effectively try to limit the power of the &#8220;test description language&#8221; to prevent the acceptance tests becoming script like.</p>
<p>Interesting food for thought &#8211; I know that many of my Fitnesse tests exhibit this codesmell</p>
]]></content:encoded>
			<wfw:commentRss>http://davidlaing.com/2010/06/16/fitnesse-smell-executable-requirements-that-look-like-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utils anti-pattern &amp; AutoMapper</title>
		<link>http://davidlaing.com/2009/06/02/utils-anti-pattern-automapper/</link>
		<comments>http://davidlaing.com/2009/06/02/utils-anti-pattern-automapper/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 09:18:41 +0000</pubDate>
		<dc:creator>mrdavidlaing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Code smells]]></category>
		<category><![CDATA[automapper]]></category>
		<category><![CDATA[utils-anti-pattern]]></category>

		<guid isPermaLink="false">http://davidlaing.com/?p=190</guid>
		<description><![CDATA[These are more for my reference purposes &#8211; hopefully you&#8217;ll find them useful:
If you&#8217;re about to name a class **Util; think harder &#8211; there is a better name that discribes what that class is for:
Chriss Missal has some advice for you
Faced with the prospect of heaps of left hand side => right hand side code [...]]]></description>
			<content:encoded><![CDATA[<p>These are more for my reference purposes &#8211; hopefully you&#8217;ll find them useful:</p>
<p>If you&#8217;re about to name a class **Util; think harder &#8211; there is a better name that discribes what that class is for:<br />
<a href="http://www.lostechies.com/blogs/chrismissal/archive/2009/06/01/anti-patterns-and-worst-practices-utils-class.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.lostechies.com/blogs/chrismissal/archive/2009/06/01/anti-patterns-and-worst-practices-utils-class.aspx');">Chriss Missal has some advice for you</a></p>
<p>Faced with the prospect of heaps of left hand side => right hand side code in your DTO of anti-corruption layer?  Consider <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/01/22/automapper-the-object-object-mapper.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/01/22/automapper-the-object-object-mapper.aspx');">Jimmy Bogard&#8217;s Automapper</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidlaing.com/2009/06/02/utils-anti-pattern-automapper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Functions with side effects are just rude!</title>
		<link>http://davidlaing.com/2009/02/25/functions-with-side-effects-are-just-rude/</link>
		<comments>http://davidlaing.com/2009/02/25/functions-with-side-effects-are-just-rude/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 14:30:26 +0000</pubDate>
		<dc:creator>mrdavidlaing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Code smells]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://davidlaing.com/?p=155</guid>
		<description><![CDATA[Today I fell into a trap when using a function that had a side effect &#8211; it unexpectedly changed an input parameter; causing a later statement to fail.  Debugging took an age!
For example, consider the following function:

[-]?View Code CSHARP1
      string StringReplace&#40;string haystack, string needle&#41;

If this function is side-effect free, [...]]]></description>
			<content:encoded><![CDATA[<p>Today I fell into a trap when using a function that had a side effect &#8211; it unexpectedly changed an input parameter; causing a later statement to fail.  Debugging took an age!</p>
<p>For example, consider the following function:</p>

<div id="wp_codebox_msgheader"><span class="right"><a href="javascript:;" onclick="toggle_collapse('p1553');">[<span id="p1553_symbol">-</span>]</a><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p155code3'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div id="wp_codebox"><table width="100%" ><tr id="p1553"><td width="1%" class="line_numbers"><pre>1
</pre></td><td class="code" id="p155code3"><pre class="csharp">      <span style="color: #FF0000;">string</span> StringReplace<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> haystack, <span style="color: #FF0000;">string</span> needle<span style="color: #000000;">&#41;</span></pre></td></tr></table></div>

<p>If this function is side-effect free, we can use it without fear like this:</p>

<div id="wp_codebox_msgheader"><span class="right"><a href="javascript:;" onclick="toggle_collapse('p1554');">[<span id="p1554_symbol">-</span>]</a><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p155code4'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div id="wp_codebox"><table width="100%" ><tr id="p1554"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p155code4"><pre class="csharp">        <span style="color: #FF0000;">string</span> menagerie <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;cat,dog,bee,llama&quot;</span><span style="color: #008000;">;</span>
        <span style="color: #FF0000;">string</span> catFreeMenagerie <span style="color: #008000;">=</span> StringReplace<span style="color: #000000;">&#40;</span>menagerie, <span style="color: #666666;">&quot;cat&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #FF0000;">string</span> beeFreeMengerie <span style="color: #008000;">=</span> StringReplace<span style="color: #000000;">&#40;</span>menagerie, <span style="color: #666666;">&quot;eric&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        Assert.<span style="color: #0000FF;">AreEqual</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;,dog,fish,llama&quot;</span>, catFreeMenagerie<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        Assert.<span style="color: #0000FF;">AreEqual</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;cat,dog,,llama&quot;</span>, beeFreeMengerie<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>However, if StringReplace() had the side effect of also changing the passed in haystack, then the second Assert would fail, because the first StringReplace has the unexpected side effect of changing one of its arguments.</p>
<p>Evans in the DDD book has quite a bit to say about this; arguing that <a href="http://my.safaribooksonline.com/0321125215/ch10lev1sec2" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://my.safaribooksonline.com/0321125215/ch10lev1sec2');">having side effect free functions goes a long way towards making a supple design</a></p>
<p><a href="http://webmat.wordpress.com/2007/12/13/an-easy-way-to-make-your-code-more-testable/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://webmat.wordpress.com/2007/12/13/an-easy-way-to-make-your-code-more-testable/');">Side effect free functions also make testing &#038; refactoring easier</a> (less state to worry about etc)</p>
<p>Remember, a function that changes its parameters is rude, and should not be trusted!</p>
<p>PS:  <a href="http://lyrics.doheth.co.uk/songs/monty-python/sings/eric-the-half-a-bee.php" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://lyrics.doheth.co.uk/songs/monty-python/sings/eric-the-half-a-bee.php');">Eric the half a bee lyrics</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidlaing.com/2009/02/25/functions-with-side-effects-are-just-rude/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
