<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Cav's Weblog</title>
	<atom:link href="http://craigcav.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://craigcav.wordpress.com</link>
	<description>A .Net Developer's Blog</description>
	<lastBuildDate>Tue, 22 Sep 2009 07:00:42 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='craigcav.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/ec6debe8b9f92d5fc39a0c78fdfc226d?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Cav's Weblog</title>
		<link>http://craigcav.wordpress.com</link>
	</image>
			<item>
		<title>LINQ: Each iterator with exposed Index</title>
		<link>http://craigcav.wordpress.com/2009/09/21/linq-each-iterator-with-exposed-index/</link>
		<comments>http://craigcav.wordpress.com/2009/09/21/linq-each-iterator-with-exposed-index/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 19:49:53 +0000</pubDate>
		<dc:creator>craigcav</dc:creator>
				<category><![CDATA[LINQ]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://craigcav.wordpress.com/2009/09/21/linq-each-iterator-with-exposed-index/</guid>
		<description><![CDATA[The Each Iterator
I’ve noticed a really handy extension method crop-up in several open source tools and frameworks that I’ve worked with; the each iterator. This simple extension method allows an action to be performed on each element of a source collection. The action is specified by providing a lambda expression as a parameter to the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=54&subd=craigcav&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>The Each Iterator</h4>
<p>I’ve noticed a really handy extension method crop-up in several open source tools and frameworks that I’ve worked with; the each iterator. This simple extension method allows an action to be performed on each element of a source collection. The action is specified by providing a lambda expression as a parameter to the Each method. This allows for a more succinct way of expressing an iteration, where previous to .NET 3.5, a foreach statement may have been used.</p>
<p>This:</p>
<pre class="code"><span style="color:blue;">foreach</span>( <span style="color:blue;">var </span>item <span style="color:blue;">in </span>collection)
{
<span style="color:green;">    </span>item.DoSomething()
}</pre>
<p>becomes:</p>
<pre class="code">collection.Each(item=&gt;item.DoSomething())</pre>
<p>A simple implementation of this can be found in the Source for <a href="http://code.google.com/p/fubumvc/" target="_blank">FubuMVC</a>:</p>
<pre class="code">[<span style="color:#2b91af;">DebuggerStepThrough</span>]
<span style="color:blue;">public static </span><span style="color:#2b91af;">IEnumerable</span>&lt;T&gt; Each&lt;T&gt;(<span style="color:blue;">this </span><span style="color:#2b91af;">IEnumerable</span>&lt;T&gt; values, <span style="color:#2b91af;">Action</span>&lt;T&gt; eachAction)
{
    <span style="color:blue;">foreach</span>( <span style="color:blue;">var </span>item <span style="color:blue;">in </span>values )
    {
        eachAction(item);
    }

    <span style="color:blue;">return </span>values;
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<h3>The need for an index</h3>
<p>For a recent piece of work, I wanted to expose the current elements index. The index could then be used, for example, for alternating row styles like this:</p>
<pre class="code"><span style="background:#ffee62;">&lt;%</span>  form.Items.Each((item, i) =&gt; 

{<span style="background:#ffee62;">%&gt;

</span>     <span style="color:blue;">&lt;</span><span style="color:#a31515;">tr </span><span style="color:red;">class</span><span style="color:blue;">='hidden </span><span style="background:#ffee62;">&lt;%</span>= i % 2 == 0 ? "item" : "altitem" <span style="background:#ffee62;">%&gt;</span><span style="color:blue;">'&gt;

          &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">class</span><span style="color:blue;">="first"&gt;</span><span style="color:red;">&amp;nbsp;</span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;

           &lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">= </span>item.SomeField <span style="background:#ffee62;">%&gt;</span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;

           &lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">= </span>expense.SomeValue <span style="background:#ffee62;">%&gt;</span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
</span><span style="color:blue;">
      &lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;

 </span><span style="background:#ffee62;">&lt;%</span>}<span style="background:#ffee62;">%&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The syntax used for the Each overload is similar to the <a href="http://msdn.microsoft.com/en-us/library/bb534869.aspx" target="_blank">overload for select()</a> in System.Linq.</p>
<h3>The implementation</h3>
<p>Here is the implementation I’m currently using to achieve this:</p>
<pre class="code">[<span style="color:#2b91af;">DebuggerStepThrough</span>]
<span style="color:blue;">public static </span><span style="color:#2b91af;">IEnumerable</span>&lt;T&gt; Each&lt;T&gt;(<span style="color:blue;">this </span><span style="color:#2b91af;">IEnumerable</span>&lt;T&gt; values, Action&lt;T, <span style="color:blue;">int</span>&gt; eachAction)
{
    <span style="color:blue;">return </span>values.Select((vals, i) =&gt; <span style="color:blue;">new </span>{ Values = vals, Index = i })
        .Each(x =&gt; eachAction(x.Values, x.Index))
        .Select(x =&gt; x.Values);
}</pre>
<p>This method uses the overload of select() to return the original collection with an index for each item (projected into an anonymous type). This anonymous type provides us the index we need to perform the provided action. We then iterate over this new collection of anonymous types, to perform the action; we can use the previously show Each implementation (from Fubu) to do this. Finally we select the original values whose elements have now had the action performed on them, and return them.</p>
<p> </p>
<p>Hopefully someone else may find this useful too!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/craigcav.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/craigcav.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/craigcav.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/craigcav.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/craigcav.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/craigcav.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/craigcav.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/craigcav.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/craigcav.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/craigcav.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=54&subd=craigcav&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://craigcav.wordpress.com/2009/09/21/linq-each-iterator-with-exposed-index/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/777bee51acb2cb22f6f81177a8e446af?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">craigcav</media:title>
		</media:content>
	</item>
		<item>
		<title>Why share knowledge?</title>
		<link>http://craigcav.wordpress.com/2009/09/21/why-share-knowledge/</link>
		<comments>http://craigcav.wordpress.com/2009/09/21/why-share-knowledge/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 18:08:22 +0000</pubDate>
		<dc:creator>craigcav</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Knowledge Sharing]]></category>

		<guid isPermaLink="false">http://craigcav.wordpress.com/2009/09/21/why-share-knowledge/</guid>
		<description><![CDATA[I’ve been watching the Continuous Integration Workshop video that Eric Hexter and Jeffrey Palermo presented and that Headspring Systems kindly made available on their website.&#160; Quite early into this video, Jeffery gives a refreshing perspective providing some insight into why Headspring are happy to share knowledge through mechanisms like OSS, free workshops and blogs. 
We [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=47&subd=craigcav&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I’ve been watching the <a href="http://www.lostechies.com/blogs/hex/archive/2009/09/17/video-of-the-continuous-integration-workshop.aspx" target="_blank">Continuous Integration Workshop</a> video that <a href="http://www.lostechies.com/blogs/hex/default.aspx" target="_blank">Eric Hexter</a> and <a href="http://jeffreypalermo.com/" target="_blank">Jeffrey Palermo</a> presented and that Headspring Systems kindly made available on their website.&#160; Quite early into this video, Jeffery gives a refreshing perspective providing some insight into why Headspring are happy to share knowledge through mechanisms like OSS, free workshops and blogs. </p>
<blockquote><p><font color="#444444">We want to be working on problems that the industry hasn’t solved.</font></p>
</blockquote>
<p>Jeffery mentions that at Headspring, they make use of many open source projects and that this allows them to focus on solving new problems, and move forward efficiently. This allows them to focus on delivering value to their customers rather than having to spend time re-inventing the wheel. </p>
<p>Having looked into this further, I found the following quote on Headsprings website:</p>
<blockquote><p>Because so much of our efficiency comes from open-source sharing and re-use of successful code modules, we believe in the power of open source. So much so that we frequently share our own code with other developers; yes, even our competitors</p>
</blockquote>
<p>They embrace giving back to the community – presenting the problems that they have solved, such that others may benefit in the same way.</p>
<p>&#160;</p>
<p>I find this attitude very refreshing indeed.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/craigcav.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/craigcav.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/craigcav.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/craigcav.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/craigcav.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/craigcav.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/craigcav.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/craigcav.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/craigcav.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/craigcav.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=47&subd=craigcav&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://craigcav.wordpress.com/2009/09/21/why-share-knowledge/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/777bee51acb2cb22f6f81177a8e446af?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">craigcav</media:title>
		</media:content>
	</item>
		<item>
		<title>Upgrading a webforms project to an ASP.NET MVC application</title>
		<link>http://craigcav.wordpress.com/2009/09/09/upgrading-a-webforms-project-to-an-asp-net-mvc-application/</link>
		<comments>http://craigcav.wordpress.com/2009/09/09/upgrading-a-webforms-project-to-an-asp-net-mvc-application/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 14:13:03 +0000</pubDate>
		<dc:creator>craigcav</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Webforms]]></category>

		<guid isPermaLink="false">http://craigcav.wordpress.com/2009/09/09/upgrading-a-webforms-project-to-an-asp-net-mvc-application/</guid>
		<description><![CDATA[In a newly created ASP.NET MVC application, Visual Studio is quite friendly to us, and provides us nice little menus for creating our controllers/views:

This menu does is not provided however, for any existing apps that we may want to migrate to using ASP.NET MVC. 
How can we tell Visual Studio to treat this web app [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=46&subd=craigcav&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In a newly created ASP.NET MVC application, Visual Studio is quite friendly to us, and provides us nice little menus for creating our controllers/views:</p>
<p><img alt="The New Project dialog box" src="http://static.asp.net/asp.net/images/mvc/34/CS/image002.jpg" /></p>
<p>This menu does is not provided however, for any existing apps that we may want to migrate to using ASP.NET MVC. </p>
<p>How can we tell Visual Studio to treat this web app as an ASP.NET MVC app? I couldn’t find an immediately obvious way to do this, and it took me more than a simple google search to figure this one out, so here’s what to do:</p>
<ol>
<li>Unload the web project (right clicking on the project within Visual Studio –&gt; Unload Project)</li>
<li>Find the tag &lt;ProjectTypeGuids&gt;</li>
<li>Add the guid {603c0e0b-db56-11dc-be95-000d561079b0};</li>
<li>Reload the project</li>
<li>The new menus should now be available! (you should probably now go ahead and add the Controllers and Views folders)</li>
</ol>
<p>&#160;</p>
<p>Hopefully this helps someone else too!</p>
<p>&#160;</p>
<p><strong>*disclaimer*</strong> <em>This worked for me, but I place no guarantees that it will work for you too!! If your computer explodes, your cat passes away, or you end up getting a divorce, please don’t blame me!</em>&#160;<strong> *disclaimer*</strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/craigcav.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/craigcav.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/craigcav.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/craigcav.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/craigcav.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/craigcav.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/craigcav.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/craigcav.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/craigcav.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/craigcav.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=46&subd=craigcav&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://craigcav.wordpress.com/2009/09/09/upgrading-a-webforms-project-to-an-asp-net-mvc-application/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/777bee51acb2cb22f6f81177a8e446af?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">craigcav</media:title>
		</media:content>

		<media:content url="http://static.asp.net/asp.net/images/mvc/34/CS/image002.jpg" medium="image">
			<media:title type="html">The New Project dialog box</media:title>
		</media:content>
	</item>
		<item>
		<title>Best and Worst Practises in Unit Testing</title>
		<link>http://craigcav.wordpress.com/2009/08/27/best-and-worst-practises-in-unit-testing/</link>
		<comments>http://craigcav.wordpress.com/2009/08/27/best-and-worst-practises-in-unit-testing/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 10:12:08 +0000</pubDate>
		<dc:creator>craigcav</dc:creator>
				<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Best Practice]]></category>

		<guid isPermaLink="false">http://craigcav.wordpress.com/2009/08/27/best-and-worst-practises-in-unit-testing/</guid>
		<description><![CDATA[
Ok, so I had been in the process of writing a blog to summarize my opinions on TDD etc, and this article popped up on my feed reader – it covers a good deal of the things I had wanted to discuss, and is summarized in a very well constructed way. So rather repeating everything, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=43&subd=craigcav&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:10pt;">Ok, so I had been in the process of writing a blog to summarize my opinions on TDD etc, and <a href="http://blog.codeville.net/2009/08/24/writing-great-unit-tests-best-and-worst-practises/">this</a> article popped up on my feed reader – it covers a good deal of the things I had wanted to discuss, and is summarized in a very well constructed way. So rather repeating everything, I’ll focus on a couple the issues discussed that I feel are important. </span></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">The point I’d like to emphasize in this article, that truly strikes a chord with me is:
</p>
<p>   </span></p>
<blockquote><p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">&#160;</span><i><span style="font-family:&quot;color:#1f497d;font-size:11pt;">a suite of bad unit tests is immensely painful: it doesn’t prove anything clearly, and can severely inhibit your ability to refactor or alter your code in any way</span></i></p>
</blockquote>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">In fact, I can’t emphasize this point enough. A suite of bad tests <b>inhibit</b> change. Brittle unit tests, like brittle code, need to be refactored/replaced. I think the points made under the section “Name your unit tests clearly and consistently” I think are crucial here. Just today for instance, I came across the following tests methods in a class named </span><span style="font-family:&quot;color:#2b91af;font-size:10pt;">DutyAssignmentChecks</span><span style="font-family:&quot;color:#1f497d;font-size:11pt;">:</span></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;"></span><span style="font-family:&quot;font-size:10pt;">SeverityLevels()</span></p>
<p class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"></span><span style="font-family:&quot;font-size:10pt;">ViolationChecks()</span></p>
<p class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"></span><span style="font-family:&quot;font-size:10pt;">WarningChecks()</span></p>
<p class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"></span><span style="font-family:&quot;font-size:10pt;">TranslatedMessage()</span><span style="font-family:&quot;color:#1f497d;font-size:11pt;">
</p>
<p>   </span></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">
<p>&#160;</p>
<p>   </span></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">I was only looking at the test code so get a feel for the current behavior of the system; after all, tests should be executable specifications that define the behavior of our code, what better way to document the system! Looking at this “unit test” code however did not help one bit. Maintenance is hard when you don’t know what you’re maintaining. If I break these tests when modifying the original code base, what value do these tests provide? If I’m changing the expected behavior of the system, then breaking a test may be valid, but how am I to know this is the case, if I can’t deduce what the expected behavior under test is! The article suggests using&#160; the <b>subject</b>, the <b>scenario</b>, and the <b>result</b> in the test name to clarify the behavior under test. This pattern of specifying is the basis of what has evolved into the Behavior Driven Development technique coined by Dan North.&#160;&#160;
</p>
<p>   </span></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">
<p>&#160;</p>
<p>   </span></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">The style of text naming <a href="http://stevenharman.net/blog/archive/2009/05/27/toward-a-better-use-of-context-specification.aspx">I prefer</a> is as follows:
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#cc7832;font-size:8pt;" lang="EN">using</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">Skynet.Core
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#cc7832;font-size:8pt;" lang="EN">public</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#cc7832;font-size:8pt;" lang="EN">class</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">when_initializing_core_module : concerns
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN"> {</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">SkynetCoreModule _core;</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;&#160;
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#cc7832;font-size:8pt;" lang="EN">public</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#cc7832;font-size:8pt;" lang="EN">void</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">context()</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">{</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#9933cc;font-size:8pt;" lang="EN">//we&#8217;ll stub it&#8230;you know&#8230;just in case</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">var skynetController = stub&lt;ISkynetMasterController&gt;();</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">_core =</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#cc7832;font-size:8pt;" lang="EN">new</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">SkynetCoreModule(skynetController);
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">_core.Initialize();
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160;&#160;&#160; }
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;&#160;
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">[Specification]
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#cc7832;font-size:8pt;" lang="EN">public</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#cc7832;font-size:8pt;" lang="EN">void</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">it_should_not_become_self_aware()</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160; {
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">_core.should_not_have_received_the_call(x =&gt; x.InitializeAutonomousExecutionMode());
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">&#160;&#160;&#160;&#160; }
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;&#160;
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">[Specification]</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; <span>&#160;</span></span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#cc7832;font-size:8pt;" lang="EN">public</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#cc7832;font-size:8pt;" lang="EN">void</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN"> </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">it_should_default_to_human_friendly_mode()</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">&#160; <span>&#160;</span>&#160; {
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">&#160; <span>&#160;</span>&#160;&#160;&#160; _core.AssessHumans().should_equal(RelationshipTypes.Friendly);
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160; <span>&#160;</span></span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN">&#160;&#160;&#160; }
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; </span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160;&#160;
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; <span>&#160;</span></span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#9933cc;font-size:8pt;" lang="EN">// more specifications under this same context</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160;&#160;&#160; <span>&#160;</span></span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">&#160; </span><span style="line-height:110%;font-family:consolas;color:#9933cc;font-size:8pt;" lang="EN">// &#8230;</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p style="line-height:110%;" class="MsoNormal"><span style="line-height:110%;font-family:consolas;color:#2b91af;font-size:8pt;" lang="EN">&#160; <span>&#160;</span>&#160;</span><span style="line-height:110%;font-family:consolas;color:#1f497d;font-size:8pt;" lang="EN"> }</span><span style="line-height:110%;font-family:consolas;color:white;font-size:8pt;" lang="EN">
</p>
<p>   </span></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">I think this kind of style of testing greatly improves the clarity and purpose of both the test, and the therefore subject under test.
</p>
<p>   </span></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">The only point the article suggests that I’d take with a small pinch of salt is in the section “Unit testing is not about finding bugs”. I think the author slightly underplays the effectiveness of unit tests detecting regression bugs when you’re making any changes to the <b><i>existing code</i></b>. He does mention that unit testing can be effective in finding bugs when refactoring,&#160; which I completely agree with – it’s this factor that makes refactoring confidently possible. I’d also argue however, that it helps find bugs introduced when a developer is <b>extending </b>the code base without following the <a href="http://www.lostechies.com/blogs/gabrielschenker/archive/2009/02/13/the-open-closed-principle.aspx">Open/Closed Principal</a>. In this scenario, the developer is <b>modifying</b> and existing code base to add a new feature or function. Although this scenario is undesirable (see the link to O/C P for details), and I would rather see the developers trained in good OO practice, in my experience I would say this scenario is extremely common in teams without much experience in good OO development. Under these conditions, unit tests are still quiet valuable in finding regression bugs.
</p>
<p>   </span></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">
<p>&#160;</p>
<p>   </span></p>
<p class="MsoNormal"><span style="font-family:&quot;color:#1f497d;font-size:11pt;">What do you think?
</p>
<p>   </span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/craigcav.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/craigcav.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/craigcav.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/craigcav.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/craigcav.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/craigcav.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/craigcav.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/craigcav.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/craigcav.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/craigcav.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=43&subd=craigcav&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://craigcav.wordpress.com/2009/08/27/best-and-worst-practises-in-unit-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/777bee51acb2cb22f6f81177a8e446af?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">craigcav</media:title>
		</media:content>
	</item>
		<item>
		<title>Why not Make Every Method Virtual?</title>
		<link>http://craigcav.wordpress.com/2009/08/16/why-not-make-every-method-virtual/</link>
		<comments>http://craigcav.wordpress.com/2009/08/16/why-not-make-every-method-virtual/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 12:54:37 +0000</pubDate>
		<dc:creator>craigcav</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Virtual Methods]]></category>

		<guid isPermaLink="false">http://craigcav.wordpress.com/2009/08/16/why-not-make-every-method-virtual/</guid>
		<description><![CDATA[In an effort to make my blog suck less, I figured I’d post my response to Ward Bells Do not Make Every Method Virtual. He carries on the discussion of whether or not .NET methods should be made virtual by default, as they are in Java. You should read his post before mine, as this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=40&subd=craigcav&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In an effort to make my <a href="http://www.hanselman.com/blog/BlogInteresting32WaysToKeepYourBlogFromSucking.aspx" target="_blank">blog suck less</a>, I figured I’d post my response to Ward Bells <a href="http://neverindoubtnet.blogspot.com/2009/08/do-not-make-every-method-virtual.html" target="_blank">Do not Make Every Method Virtual</a>. He carries on the discussion of whether or not .NET methods should be made virtual by default, as they are in Java. You should read his post before mine, as this will establish the context of everything that follows (and if you don’t already subscribe to his blog,&#160; be sure to add it – you’ve been missing out on a lot of good stuff). </p>
<p>All done? Ok, I’ll continue.</p>
<h4>Reviewing case against default virtual methods</h4>
<p><u></u></p>
<p><u>Unwanted Extension Points</u></p>
<p>Wards &quot;elevator&quot; example demonstrates that we should not make all methods virtual, since it exposes extension points where we do not want them. Let’s have a look at the reason this particular extension point is not wanted. </p>
<p>The elevator.Up() method has responsibilities for moving the elevator up and&#160; closing doors etc. These responsibilities need to be chained in the right order to function safely; we do not wish client code to break the desired behaviour by inadvertently calling Up() at the wrong time.</p>
<p>This seems to highlight a smell that the <a href="http://www.lostechies.com/blogs/jason_meridth/archive/2008/03/26/ptom-single-responsibility-principle.aspx" target="_blank">single responsibility principle</a> is not being adhered to in the elevator class. Since this issue is cause by incorrect ordering of multiple responsibilities. By adhering to SRP, separating out the different behaviours from the responsibility of coordinating them, we can avoid this conflict. We can then keep this method as virtual, and benefit from an additional extension hook safely. </p>
<p><u>Explicit Contracts</u></p>
<p>Paraphrasing another point made (I hope Ward will correct me if this is a misrepresentation) is that we may want to be very explicit about the points in which an application can be extended. Marking a method as virtual is a way of explicitly showing your &quot;approved&quot; extension hook. </p>
<p>Arguably, I prefer to see my &quot;extension hooks&quot; more explicitly than a virtual method. As an application developer looking for a &quot;seam&quot; to extend, I would favour seeing an interface that I can implement, over inheriting from a class and overriding it&#8217;s virtual methods. This is mainly because to interfaces tend to be more discoverable than virtual methods. </p>
<p><u>Open/Closed Principle</u></p>
<p>Lastly, I have a different perspective on the <a href="http://www.lostechies.com/blogs/joe_ocampo/archive/2008/03/21/ptom-the-open-closed-principle.aspx" target="_blank">OCP</a>. I believe &quot;closed for modification&quot; to be in reference to the actual LOC contained in the class rather than &quot;closing off&quot; modifications to behaviour. I agree however, that making all methods virtual does open up a greater susceptibility to the violation of LSP. </p>
<h4></h4>
<h4>Summary</h4>
<p>The arguments made against methods being virtual as default mostly seem to fit under the umbrella of protecting yourself against unwitting developers. I think there are safer ways to do this whilst still obtaining the flexibility provided when all methods are virtual by default. </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/craigcav.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/craigcav.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/craigcav.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/craigcav.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/craigcav.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/craigcav.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/craigcav.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/craigcav.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/craigcav.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/craigcav.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=40&subd=craigcav&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://craigcav.wordpress.com/2009/08/16/why-not-make-every-method-virtual/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/777bee51acb2cb22f6f81177a8e446af?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">craigcav</media:title>
		</media:content>
	</item>
		<item>
		<title>Refactoring a static method (on a generic class) to an extension method‏</title>
		<link>http://craigcav.wordpress.com/2009/08/10/refactoring-a-static-method-on-a-generic-class-to-an-extension-method/</link>
		<comments>http://craigcav.wordpress.com/2009/08/10/refactoring-a-static-method-on-a-generic-class-to-an-extension-method/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 22:30:52 +0000</pubDate>
		<dc:creator>craigcav</dc:creator>
				<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Resharper]]></category>

		<guid isPermaLink="false">http://craigcav.wordpress.com/2009/08/10/refactoring-a-static-method-on-a-generic-class-to-an-extension-method/</guid>
		<description><![CDATA[The Goal
I needed to perform this refactoring today, and it took me a few mins to figure out how to do this in a safe way using resharper. My goal was to refactor usages like:
Mapper&#60;DestinationType&#62;.Map(Source)


to use an extension method so I can use the syntax similar to:
Source.MapTo&#60;DestinationType&#62;();
which I find to be less verbose, more discoverable, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=37&subd=craigcav&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>The Goal</h4>
<p>I needed to perform this refactoring today, and it took me a few mins to figure out how to do this in a safe way using <a href="http://www.jetbrains.com/resharper/" target="_blank">resharper</a>. My goal was to refactor usages like:</p>
<p style="background:white;" class="ecmsonormal"><font face="Courier New"><font color="#23a5ab" face="Courier New">Mapper</font>&lt;<font color="#23a5ab">DestinationType</font>&gt;.Map(Source)</font></p>
</p>
</p>
<p>to use an extension method so I can use the syntax similar to:</p>
<p style="background:white;" class="ecmsonormal"><font face="Courier New">Source.MapTo&lt;<font color="#23a5ab">DestinationType</font>&gt;();</font></p>
<p>which I find to be less verbose, more discoverable, and more readable. This however was slightly more difficult than I hoped; resharper didn’t let me do this in a single step (how lazy of me).</p>
<h4>The Problem</h4>
<p style="background:white;" class="ecmsonormal"><span style="font-family:&quot;color:#444444;font-size:10pt;"></span></p>
<p>The original code* looked similar in structure to this:</p>
</p>
<p style="text-align:justify;line-height:21.6pt;margin-bottom:0;background:white;" class="MsoNormal"><span style="font-family:&quot;color:blue;font-size:10pt;" lang="EN"></span></p>
<p><font face="Courier New"><font color="#0000ff">public abstract class</font> <font color="#23a5ab" face="Courier New">Mapper</font>&lt;TDestination&gt;</font></p>
<p><font face="Courier New">{</font></p>
<p><font face="Courier New">&#160;&#160; <font color="#0000ff">public static</font> TDestination Map(object source) </font></p>
<p><font face="Courier New">&#160;&#160; {</font></p>
<p><font face="Courier New">&#160;&#160;&#160;&#160;&#160; //do mapping here</font></p>
<p><font face="Courier New">&#160;&#160;&#160;&#160;&#160; <font color="#0000ff">return</font> destination;</font></p>
<p><font face="Courier New">&#160;&#160; }</font></p>
<p><font face="Courier New">}</font></p>
<p>Since <font color="#23a5ab" face="Courier New">Mapper</font> is not a static class, we cannot use <a href="http://www.jetbrains.com/resharper/" target="_blank">resharpers</a> built in “convert static to extension method” refactoring straight up; extension methods can only live in a static class. We could move this method to a static class, say <font color="#23a5ab" face="Courier New">MapperExtensions</font>, such that we can perform “convert static to extension method”, but to do this we also require the generic type parameter TDestination that lives on the <font color="#23a5ab" face="Courier New">Mapper</font> class. There isn’t a refactoring (that I am aware of/could find with a quick google) to add a generic type parameter to a method signature and adding this in by hand would break all my code that invokes this method. We cannot make the <font color="#23a5ab" face="Courier New">Mapper</font> class static either, since it is an abstract class. This was looking like it could be a bit of a pain.</p>
<p><em>*The example (mapping) is actually contrived &#8211; I’ve made up a example here that is representative of the structure of the problem, rather than use the actual code. This was to avoid breaching the IP rules of the company I work for. In an actual mapper, the Map method is more likely to be an instance method rather than static, and since Mapping it is the primary responsibility of the class, it is not advisable for the Map method to be implemented as an extension method.</em></p>
<h4>The Solution</h4>
<p style="background:white;" class="ecmsonormal"><u>Step 1: Extract Method</u></p>
<p style="background:white;" class="ecmsonormal">First of all, we can use the <a href="http://www.jetbrains.com/resharper/features/code_refactoring.html#Extract_Method" target="_blank">extract method</a> refactoring to extract the contents of the original method into another method. We can then use this newly created method as a base to make a any further changes (like adding the generic type parameter) without breaking anything that invokes our original code. After this step, we have:</p>
<p> <span style="font-family:&quot;color:blue;font-size:10pt;" lang="EN"></span>
<p><span style="font-family:&quot;color:#444444;font-size:10pt;" lang="EN"></span></p>
<p style="margin-bottom:0;" class="MsoNormal"><font face="Courier New"><font color="#0000ff">public abstract class</font> <font color="#23a5ab" face="Courier New">Mapper</font>&lt;TDestination&gt; </font></p>
</p>
<p><font face="Courier New">{</font></p>
<p><font face="Courier New">&#160;&#160; <font color="#0000ff">public static</font> TDestination Map(<font color="#0000ff">object</font> source) </font></p>
<p><font face="Courier New">&#160;&#160; {</font></p>
<p><font face="Courier New">&#160;&#160;&#160;&#160;&#160; <font color="#0000ff">return</font> MapTo&lt;TDestination&gt;(source);</font></p>
<p><font face="Courier New">&#160;&#160; } </font></p>
<p><font face="Courier New">&#160;&#160; <font color="#0000ff">public static</font> TDestination MapTo&lt;TDestination&gt;(<font color="#0000ff">object</font> source) </font></p>
<p><font face="Courier New">&#160;&#160; {</font></p>
<p><font face="Courier New">&#160;&#160;&#160;&#160;&#160; //do mapping here</font></p>
<p><font face="Courier New">&#160;&#160;&#160;&#160;&#160; <font color="#0000ff">return</font> destination;</font></p>
<p><font face="Courier New">&#160;&#160; }</font></p>
<p><font face="Courier New">}</font></p>
<p><u>Step 2: Move Method</u></p>
</p>
<p style="margin-bottom:0;" class="MsoNormal">
<p>Since we now have a static method with the required generic type parameter, we can now use the “<a href="http://www.jetbrains.com/resharper/features/code_refactoring.html#Move_Static_Member" target="_blank">Move Method</a>” refactoring to move <font face="Courier New">MapTo</font> to its new home, the static class <font color="#23a5ab" face="Courier New">MapperExtensions</font>. </p>
</p>
<p style="background:white;" class="ecmsonormal"><u>Step 3: Convert static to extension method</u></p>
<p>We’re now all set to use <a href="http://www.jetbrains.com/resharper/features/code_refactoring.html#Convert_Static_to_Extension_Method" target="_blank">this refactoring</a> – and we’re nearly there!</p>
<p><u>Step 4: inline method</u></p>
<p>We can now make the original call to <font face="Courier New">Map</font> an <a href="http://www.jetbrains.com/resharper/features/code_refactoring.html#Inline_Method" target="_blank">inline method</a>. This will essentially replace all existing calls from using <font face="Courier New">Map</font> to use the <font face="Courier New">MapTo</font> extension method.</p>
<h4>The End Result</h4>
<p>The finished article now looks like this:</p>
<p>
<p><font face="Courier New"><font color="#0000ff">public static class </font><font color="#23a5ab" face="Courier New">MapperExtensions</font></font></p>
</p>
<p><font face="Courier New">{</font></p>
<p><font face="Courier New">&#160;&#160; <font color="#0000ff">public static </font>TDestination MapTo&lt;TDestination&gt;(<font color="#0000ff">this object</font> source)</font></p>
<p><font face="Courier New">&#160;&#160; {</font></p>
<p><font face="Courier New">&#160;&#160;&#160;&#160;&#160; //do mapping here</font></p>
<p><font face="Courier New">&#160;&#160;&#160;&#160;&#160; <font color="#0000ff">return </font>destination;</font></p>
<p><font face="Courier New">&#160;&#160; }</font></p>
<p><font face="Courier New">}</font></p>
<p>Now we’re talking!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/craigcav.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/craigcav.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/craigcav.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/craigcav.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/craigcav.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/craigcav.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/craigcav.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/craigcav.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/craigcav.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/craigcav.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=37&subd=craigcav&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://craigcav.wordpress.com/2009/08/10/refactoring-a-static-method-on-a-generic-class-to-an-extension-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/777bee51acb2cb22f6f81177a8e446af?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">craigcav</media:title>
		</media:content>
	</item>
		<item>
		<title>Perfect is the enemy of the good</title>
		<link>http://craigcav.wordpress.com/2009/07/15/perfect-is-the-enemy-of-the-good/</link>
		<comments>http://craigcav.wordpress.com/2009/07/15/perfect-is-the-enemy-of-the-good/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 07:36:04 +0000</pubDate>
		<dc:creator>craigcav</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://craigcav.wordpress.com/2009/07/15/perfect-is-the-enemy-of-the-good/</guid>
		<description><![CDATA[I’ve spent the last few evenings catching up on some of the posts on JP Boodhoo’s blog&#160; (I’m still gutted that I can’t get the go-ahead from work to attend his Nothin’ but .NET Developer Boot Camp). In one of his posts, JP touches upon an issue that really plagues me; the trap of perfectionism.
I’ve [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=35&subd=craigcav&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I’ve spent the last few evenings catching up on some of the posts on <a href="http://blog.jpboodhoo.com/">JP Boodhoo’s blog</a>&#160; (I’m still gutted that I can’t get the go-ahead from work to attend his <a href="http://www.jpboodhoo.com/training.oo">Nothin’ but .NET Developer Boot Camp</a>). In one of his posts, JP touches upon an issue that really plagues me; the <a href="http://blog.jpboodhoo.com/AvoidTheTrapOfPerfectionism.aspx">trap of perfectionism</a>.</p>
<p>I’ve often caught myself spending longer than appropriate trying to get something done “right” first time, when it would be far more pragmatic to try the simplest thing that works then refactor. If you catch me doing this (which won’t be hard, I think I do it a lot), you have my permission to slap me!</p>
<p>I think <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/06/10/simplest-versus-first-thing-that-could-possibly-work.aspx">the trick</a> is to making this work is doing “the simplest thing” rather than “the first thing that springs to mind that might work”. It’s also important to make small steps and refactor for this approach to work, keeping technical debt to a minimum.</p>
<p>It’s definitely something I need to work on.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/craigcav.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/craigcav.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/craigcav.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/craigcav.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/craigcav.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/craigcav.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/craigcav.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/craigcav.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/craigcav.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/craigcav.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=35&subd=craigcav&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://craigcav.wordpress.com/2009/07/15/perfect-is-the-enemy-of-the-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/777bee51acb2cb22f6f81177a8e446af?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">craigcav</media:title>
		</media:content>
	</item>
		<item>
		<title>MS Stubs framework</title>
		<link>http://craigcav.wordpress.com/2009/07/06/ms-stubs-framework/</link>
		<comments>http://craigcav.wordpress.com/2009/07/06/ms-stubs-framework/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 12:51:47 +0000</pubDate>
		<dc:creator>craigcav</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Mocking]]></category>

		<guid isPermaLink="false">http://craigcav.wordpress.com/2009/07/06/ms-stubs-framework/</guid>
		<description><![CDATA[A colleague of mine recently came across Stubs &#8211; a Lightweight Stub Framework for .NET and suggested I take a look. Having used both Moq and Rhino Mocks in the past, I was intrigued, and thought I should take a closer look.

I may have gotten the wrong end-of-the-stick, but it seems that Stubs uses code-generation [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=33&subd=craigcav&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A colleague of mine recently came across <a href="http://research.microsoft.com/en-us/projects/stubs/">Stubs &#8211; a Lightweight Stub Framework for .NET</a> and suggested I take a look. Having used both <a href="http://code.google.com/p/moq/">Moq</a> and <a href="http://ayende.com/projects/rhino-mocks.aspx">Rhino Mocks</a> in the past, I was intrigued, and thought I should take a closer look.</p>
<p><img src="http://research.microsoft.com/en-us/projects/stubs/stubexample.png" /></p>
<p>I may have gotten the wrong end-of-the-stick, but it seems that Stubs uses code-generation to generate stubs, rather than the more typical dynamic code approach used by other frameworks (reflection and expression trees).</p>
<p>My initial thoughts are:</p>
<ul>
<li>I wonder how well the code-gen approach works with TDD? I don’t fancy having to re-run a tool manually every time I create a new interface; the less friction the better! </li>
<li>I generally would tend to favour dynamic code (reflection, expression trees etc) over code-gen unless performance is a key-factor, since this results in less code to maintain. It may be the case that code-gen here can make a significant reduction in execution time of tests in larger code-bases, although it would be interesting to see some stats for this. It would also be interesting to see whether this approach works out favourably on a long-running project (where interfaces are likely to change) as I can see maintenance of the stubs being a potential issue. </li>
<li>It’s good to see Microsoft favouring type-safe code rather than using magic strings as they had in other projects (like asp.net MVC) </li>
</ul>
<p>&#160;</p>
<p>I seems like this could be an interesting project to keep an eye on, but for the mean-while at least, I think I’ll stick to Rhino Mocks!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/craigcav.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/craigcav.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/craigcav.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/craigcav.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/craigcav.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/craigcav.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/craigcav.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/craigcav.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/craigcav.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/craigcav.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=33&subd=craigcav&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://craigcav.wordpress.com/2009/07/06/ms-stubs-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/777bee51acb2cb22f6f81177a8e446af?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">craigcav</media:title>
		</media:content>

		<media:content url="http://research.microsoft.com/en-us/projects/stubs/stubexample.png" medium="image" />
	</item>
		<item>
		<title>Interesting post from Oren&#8230;&#8207;</title>
		<link>http://craigcav.wordpress.com/2009/06/13/interesting-post-from-oren/</link>
		<comments>http://craigcav.wordpress.com/2009/06/13/interesting-post-from-oren/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 12:05:05 +0000</pubDate>
		<dc:creator>craigcav</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://craigcav.wordpress.com/2009/06/13/interesting-post-from-oren/</guid>
		<description><![CDATA[http://ayende.com/Blog/archive/2009/06/09/avoid-externalizing-decisions-from-your-domain-model.aspx
Extract:
Boolean methods worry me because of their implications. If you have a Boolean method here, it means that somewhere else you have an if statement that works based on this method.

The “legacy” application I took ownership of when starting at my current employer is teeming with boolean methods – UserAccount as an example of this; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=32&subd=craigcav&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://ayende.com/Blog/archive/2009/06/09/avoid-externalizing-decisions-from-your-domain-model.aspx">http://ayende.com/Blog/archive/2009/06/09/avoid-externalizing-decisions-from-your-domain-model.aspx</a></p>
<p>Extract:</p>
<blockquote><p><i>Boolean methods worry me because of their implications. If you have a Boolean method here, it means that somewhere else you have an if statement that works based on this method.</i></p>
</blockquote>
<p>The “legacy” application I took ownership of when starting at my current employer is teeming with boolean methods – UserAccount as an example of this; IsSuspended, IsActive, IsAuthenticated etc. Funnily enough if I “Find Usages” they tend to have two types of usage; making decisions as to what to display in the UI, and validating whether an action can take place.</p>
<p>Oren hasn’t suggested his preferred approach to tackling this kind of problem but I would favour:</p>
<p>a) having these boolean methods moved out of my entity, and onto a view model for when I need this data when binding a view (my repositories can retrieve “suspended” or “not-suspended” users based on specifications).</p>
<p>b) when boolean properties (like IsActive) are used to determine whether or not to display a link to an action, based on the state of the domain (like&#160; re-activate User for inactive accounts) then I’d prefer this responsibility to be delegated to to my application layer in a class responsible for application co-ordination, rather than having this logic my domain. </p>
<p>What do you think? </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/craigcav.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/craigcav.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/craigcav.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/craigcav.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/craigcav.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/craigcav.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/craigcav.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/craigcav.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/craigcav.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/craigcav.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=32&subd=craigcav&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://craigcav.wordpress.com/2009/06/13/interesting-post-from-oren/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/777bee51acb2cb22f6f81177a8e446af?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">craigcav</media:title>
		</media:content>
	</item>
		<item>
		<title>I&#8217;ve learnt so much from&#8230;</title>
		<link>http://craigcav.wordpress.com/2009/04/26/ive-learnt-so-much-from/</link>
		<comments>http://craigcav.wordpress.com/2009/04/26/ive-learnt-so-much-from/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 10:36:32 +0000</pubDate>
		<dc:creator>craigcav</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://craigcav.wordpress.com/2009/04/26/ive-learnt-so-much-from/</guid>
		<description><![CDATA[…reading blogs. This originally started with me stumbling along Los Techies (I believe it was a post by Jimmy Bogard), and adding this to my favourites. After doing the same for several other bloggers, this became unmanageable and a colleague of mine pointed me in the direction of the popular feed-reading service Google Reader.
I imagine [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=29&subd=craigcav&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>…reading blogs. This originally started with me stumbling along <a href="http://www.lostechies.com/" target="_blank">Los Techies</a> (I believe it was a post by <a href="http://www.lostechies.com/blogs/jimmy_bogard/default.aspx" target="_blank">Jimmy Bogard</a>), and adding this to my favourites. After doing the same for several other bloggers, this became unmanageable and a colleague of mine pointed me in the direction of the popular feed-reading service <a href="http://www.google.com/reader/" target="_blank">Google Reader</a>.</p>
<p>I imagine that most people reading this right now probably will have their own RSS-feed aggregator, but if they haven’t, I would definitely recommend Google Reader as it makes it very easy to keep up with new posts. I currently use the Reader application on my iPhone while on the train to/from work, so I can us this “dead-time” productively. </p>
<p>According to Google Readers “trends” feature, on average I read 12 posts a day from my 53 subscriptions. A large amount of these seem to be posted by Oren aka <a href="http://ayende.com/Blog/Default.aspx" target="_blank">Ayende Rahien</a> – I have no idea how he manages to post so often, especially considering his posts are usually very thought provoking.</p>
<p>Anyway, the reason I’m writing all this was to share links to a few of the blog-authors I feel I’ve learnt the most from (you can see my Google Reader shared items <a href="http://www.google.co.uk/reader/shared/12586852807676269750" target="_blank">here</a>). These guys are super-smart (I mean clever rather than well dressed), and almost every post I read from them is a gem. </p>
<p>In no particular order:</p>
<ul>
<li><a href="http://blog.wekeroad.com/" target="_blank">Rob Conery</a> – A fantastic, usually very entertaining writing style, with great content, especially on ASP.NET MVC. I’m also very jealous that he lives in Hawaii.</li>
<li><a href="http://www.lostechies.com/blogs/jimmy_bogard/default.aspx" target="_blank">Jimmy Bogard</a> – Every post is very clearly written and well thought out. A definite must-have on your feed-reader. Content generally covers things like SOLID principles, Agile development, and Doman-Driven Design. Author of to OSS tool <a href="http://www.codeplex.com/AutoMapper" target="_blank">AutoMapper</a>.</li>
<li><a href="http://codebetter.com/blogs/gregyoung/default.aspx" target="_blank">Grey Young</a> – A very inspiring blog, which I will read over-and over again. Content usually covers: DDD (specifically distributed domain-driven design), design patterns and agile development.</li>
<li><a href="http://codebetter.com/blogs/jeremy.miller/default.aspx" target="_blank">Jeremy Miller</a> – I’ve got a lot of respect for this guy. He’s clearly a very intelligent chap. His blog often includes writing about: Software Architecture, Design Patterns, Test Driven Development, and Alt.Net. Author of the <a href="http://structuremap.sourceforge.net/" target="_blank">StructureMap</a> IoC tool and <a href="http://fubumvc.pbwiki.com/" target="_blank">FubuMVC</a>. </li>
<li><a href="http://www.lostechies.com/blogs/chad_myers/default.aspx" target="_blank">Chad Myers</a> – Chad’s posts are always very cohesive and well written, and along with Jimmy Bogard was one of the first blog-authors to inspire me with their work. His blog often covers topics like TDD, SOLID principles, and ALT.NET. Author of <a href="http://fubumvc.pbwiki.com/" target="_blank">FubuMVC</a></li>
<li><a href="http://elegantcode.com/author/jryswyck/feed/" target="_blank">Jan Van Ryswyck</a> – Having only found Jan’s blogs on Elegant Code quite recently, it says quite a lot that he’s made it into my top list of blog-authors. His recent posts on <a href="http://elegantcode.com/2009/03/28/experimenting-with-fluent-interfaces-in-the-domain/" target="_blank">fluent</a> <a href="http://elegantcode.com/2009/03/21/progressive-interfaces/" target="_blank">interfaces</a> are typical of the inspirational pots he writes.</li>
<li><a href="http://codebetter.com/blogs/ian_cooper/" target="_blank">Ian Cooper</a> – Ian’s blog contains some great material on persistence ignorance, nhibernate, TDD and BDD, and Linq. Less active than the bloggers above, but certainly worth adding to your feed-reader.</li>
</ul>
<p>Other very good blog-authors to check out:</p>
<ul>
<li><a href="http://colinjack.blogspot.com/" target="_blank">Colin Jack</a></li>
<li><a href="http://ayende.com/Blog/Default.aspx" target="_blank">Oren Eini</a></li>
<li><a href="http://www.hanselman.com/blog/" target="_blank">Scott Hanselman</a></li>
<li><a href="http://www.goeleven.com/default.aspx" target="_blank">Yves Goeleven</a></li>
<li><a href="http://iridescence.no/" target="_blank">Fredrik Kalseth</a></li>
</ul>
<p>&#160;</p>
<p>Whose blogs would you recommend? </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/craigcav.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/craigcav.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/craigcav.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/craigcav.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/craigcav.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/craigcav.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/craigcav.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/craigcav.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/craigcav.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/craigcav.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=craigcav.wordpress.com&blog=4117366&post=29&subd=craigcav&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://craigcav.wordpress.com/2009/04/26/ive-learnt-so-much-from/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/777bee51acb2cb22f6f81177a8e446af?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">craigcav</media:title>
		</media:content>
	</item>
	</channel>
</rss>