<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>It's a .NET Life</title>
	
	<link>http://www.david-yancey.com/blog</link>
	<description>Thoughts on .NET, Agile and beyond</description>
	<lastBuildDate>Tue, 12 May 2009 20:56:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<geo:lat>32.831228</geo:lat><geo:long>-97.145939</geo:long><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/DavidYancey" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Throw Away Code (aka Spike Solution)</title>
		<link>http://feedproxy.google.com/~r/DavidYancey/~3/x6ULpCueJfs/</link>
		<comments>http://www.david-yancey.com/blog/index.php/2009/05/06/throw-away-code-aka-spike-solution/#comments</comments>
		<pubDate>Thu, 07 May 2009 01:06:42 +0000</pubDate>
		<dc:creator>david.yancey</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[XP]]></category>

		<guid isPermaLink="false">http://www.david-yancey.com/blog/index.php/2009/05/06/throw-away-code-aka-spike-solution/</guid>
		<description><![CDATA[ 
I’ve been talking with a few of my programmers the past few days about the concept of throw away code, asking them if they’ve heard of the concept, or if they’ve thought about implementing it on their teams.   All but one of them replied back to me with variations of “what a waste of time”, [...]]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>I’ve been talking with a few of my programmers the past few days about the concept of throw away code, asking them if they’ve heard of the concept, or if they’ve thought about implementing it on their teams.   All but one of them replied back to me with variations of “what a waste of time”, or “why would I want to code knowing I”m going to throw it away?”.</p>
<p><strong>Spike Solutions:</strong></p>
<p>Extreme Programming <a href="http://www.extremeprogramming.org/rules/spike.html">defines</a> spike solutions as:</p>
<blockquote><p>Create spike solutions to figure out answers to tough technical or design problems. A spike solution is a very simple program to explore potential solutions. Build a system which only addresses the problem under examination and ignore all other concerns. Most spikes are not good enough to keep, so <strong>expect to throw it away</strong>. The goal is reducing the risk of a technical problem or increase the reliability of a <a href="http://www.extremeprogramming.org/userstories.html">user story&#8217;s estimate.</a></p>
<p>When a technical difficulty threatens to hold up the system&#8217;s development put a pair of developers on the problem for a week or two and reduce the potential risk.</p></blockquote>
<p>The concept of throw away code is to practice coding to solve a technical problem, or practice implementing various design patterns / practices.  When your done practicing throw the code away and either start over, or implement what you’ve learned from the practice session.   When you’ve reached the end of your session then throw the code away and start over your next session.</p>
<p>Have a goal for each session.  Setting a goal such as learning how to implement the strategy design pattern, finding a solution for a technical / design issue, or testing out a new testing framework will help you stay focused and meet your goal.</p>
<p>Keep your practice sessions short, I like to keep them between 30min and 2hours, but never more than 2 hours.  Going past your set time for your session often times works against you and causes you to loose focus on your goal.  I’ve also experienced greater difficulty in convincing the business in approving longer session times.</p>
<p>Combining these sessions with pair programming also provides a great means for knowledge sharing with your team members. Whether you need to show a new team member your software library / framework, introduce them to TDD, or learn a new design pattern this is another good tool for you to use to help reach your goals.</p>
<p>So don’t be afraid to throw away your code.  In fact I encourage you to implement throw away coding sessions (aka spike solutions) in your team.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DavidYancey?a=x6ULpCueJfs:6Dm__HwJRIQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DavidYancey?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DavidYancey?a=x6ULpCueJfs:6Dm__HwJRIQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/DavidYancey?i=x6ULpCueJfs:6Dm__HwJRIQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DavidYancey?a=x6ULpCueJfs:6Dm__HwJRIQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/DavidYancey?i=x6ULpCueJfs:6Dm__HwJRIQ:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DavidYancey/~4/x6ULpCueJfs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-yancey.com/blog/index.php/2009/05/06/throw-away-code-aka-spike-solution/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.david-yancey.com/blog/index.php/2009/05/06/throw-away-code-aka-spike-solution/</feedburner:origLink></item>
		<item>
		<title>Code Noise Part 2!</title>
		<link>http://feedproxy.google.com/~r/DavidYancey/~3/jxBm-jklP7I/</link>
		<comments>http://www.david-yancey.com/blog/index.php/2009/02/04/code-noise-part-2-2/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 20:48:25 +0000</pubDate>
		<dc:creator>david.yancey</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://www.david-yancey.com/blog/?p=22</guid>
		<description><![CDATA[Last time we looked at what Code Noise was.  This time we are going to look at good practices for eliminating code noise.
Clean Naming:
Clean names reveal intent.
Clean names reveal intent.
Clean names reveal intent.
The point I&#8217;m trying to get across here is that good clean names reveal intent.  So what do I mean by this?  Names [...]]]></description>
			<content:encoded><![CDATA[<p>Last time we looked at what Code Noise was.  This time we are going to look at good practices for eliminating code noise.</p>
<p><strong>Clean Naming:</strong></p>
<p>Clean names reveal intent.<br />
Clean names reveal intent.<br />
Clean names reveal intent.</p>
<p>The point I&#8217;m trying to get across here is that good clean names reveal intent.  So what do I mean by this?  Names should tell what it does, why its there, and how it&#8217;s used.  You should not have to add a comment to explain what the intent is.  This applies to variables, functions, and class&#8217;s.</p>
<p>Let&#8217;s take a look at an example:  Before scrolling down to the &#8220;clean&#8221; version of this example try to determine what the intent of this code is.  After a bit of study, you will determine what the intent is.</p>
<div>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #0000ff;">public</span> List&lt;int&gt; GetThem(int num1)
        {
            List&lt;int&gt; myList = <span style="color: #0000ff;">new</span> List&lt;int&gt;();
            int num2 = 2;
            int num3 = 0;
            myList.Add(num2);
            <span style="color: #0000ff;">for</span> (num2 = 3; num2 &lt;= num1; num2 += 2)
            {
                <span style="color: #0000ff;">for</span> (num2 = 3; num2%num3 != 0; num3 += 2)
                    <span style="color: #0000ff;">if</span> (num3 == num2)
                    {
                        myList.Add(num2);
                    }
            }
            <span style="color: #0000ff;">return</span> myList;
        }</pre>
</div>
<p>Now take a look at this example we can see what the intent of function and each variable.  By taking the time to use better intent revealing names we can reduce the amount of comments needed and have cleaner code.</p>
<div>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #0000ff;">public</span> List&lt;<span style="color: #0000ff;">int</span>&gt; GetPrimeNumbers(<span style="color: #0000ff;">int</span> upperLimit)
        {
            List&lt;<span style="color: #0000ff;">int</span>&gt; PrimeNumbers = <span style="color: #0000ff;">new</span> List&lt;<span style="color: #0000ff;">int</span>&gt;();
            <span style="color: #0000ff;">int</span> testNumber = 2;
            <span style="color: #0000ff;">int</span> checkNumber = 0;
            PrimeNumbers.Add(testNumber);
            <span style="color: #0000ff;">for</span> (testNumber = 3; testNumber &lt;= upperLimit; testNumber += 2)
            {
                <span style="color: #0000ff;">for</span> (testNumber = 3; testNumber%checkNumber != 0; checkNumber += 2)
                    <span style="color: #0000ff;">if</span> (checkNumber == testNumber)
                    {
                        PrimeNumbers.Add(testNumber);
                    }
            }
            <span style="color: #0000ff;">return</span> PrimeNumbers;
        }</pre>
</div>
<p> </p>
<p><strong>Exception Handling</strong></p>
<p>Tip #1:  Avoid generic exception handling.</p>
<p>Okay now before you start spamming me with comments, emails, general hatred let me explain why.</p>
<p>Generally when we catch a generic exception its to take care of “unhandled exceptions”.  While we don’t want unhandled exceptions presented to the customer we don’t want to default to using Try/Catch blocks just to handle a generic exception.  When we handle an exception we need to know what we are handling and why.</p>
<p>Tip #2:  Instead of returning error codes throw custom exceptions.</p>
<p>Checking return codes for errors can cause unnecessary code noise .  Instead throw a custom exception and catch that exception instead.</p>
<p>Tip #3:  Wrap 3rd party COT&#8217;s exception handling in a local custom exception class.</p>
<p>Most 3rd party COT&#8217;s exceptions are meaningless to our applications.  It would be better to catch those exceptions together in a local class and throw more meaningful exceptions.</p>
<p> </p>
<p>These are just a few areas to look at when coding to help ensure clean code.</p>
<p> </p>
<p>Have fun.</p>
<p> </p>
<p>David Yancey</p>
<p><!--</p>
<div mce_tmp="1">.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, &#8220;Courier New&#8221;, courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } &#8211;></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DavidYancey?a=jxBm-jklP7I:2_15IQnz8JE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DavidYancey?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DavidYancey?a=jxBm-jklP7I:2_15IQnz8JE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/DavidYancey?i=jxBm-jklP7I:2_15IQnz8JE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DavidYancey?a=jxBm-jklP7I:2_15IQnz8JE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/DavidYancey?i=jxBm-jklP7I:2_15IQnz8JE:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DavidYancey/~4/jxBm-jklP7I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-yancey.com/blog/index.php/2009/02/04/code-noise-part-2-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.david-yancey.com/blog/index.php/2009/02/04/code-noise-part-2-2/</feedburner:origLink></item>
		<item>
		<title>Code Noise!!!</title>
		<link>http://feedproxy.google.com/~r/DavidYancey/~3/IhuG-Yvz9wI/</link>
		<comments>http://www.david-yancey.com/blog/index.php/2008/12/10/dirty-code/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 05:16:02 +0000</pubDate>
		<dc:creator>david.yancey</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.david-yancey.com/blog/index.php/2008/12/10/dirty-code/</guid>
		<description><![CDATA[If 4 letter words immediately come to mind when you do a code review&#8230;then you might have dirty code.
If you wince each time a new feature is requested to be added to your existing library of code&#8230;then you might have dirty code.
If the amount of time it takes to research a bug is inversely proportional to [...]]]></description>
			<content:encoded><![CDATA[<p>If 4 letter words immediately come to mind when you do a code review&#8230;then you might have dirty code.</p>
<p>If you wince each time a new feature is requested to be added to your existing library of code&#8230;then you might have dirty code.</p>
<p>If the amount of time it takes to research a bug is inversely proportional to the amount of time you took to develop said bug&#8230;then you might have dirty code.</p>
<p>Alright enough of my attempts to making &#8220;redneck jokes&#8221; about dirty code.  Lets take a look first at what defines dirty code.  Then we&#8217;ll take a look at some tips/tricks to refactor dirty code into what would be considered clean code.</p>
<p><strong>What makes code dirty?</strong></p>
<p>Bad Names:</p>
<p>Take a look at the code below and try to determine what each variable represents.  You&#8217;ll be able to after studying the code for a few minuets, but as programmers we should write our code so that the intent is revealed not just in the method names but also the parameter names and variable names.</p>
<pre class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">static</span> XDocument BuildXml(IEnumerable&lt;v&gt; vL)
        {
            XDocument x = <span class="kwrd">new</span> XDocument();
            XElement r= <span class="kwrd">new</span> XElement(<span class="str">"searchResults"</span>);
            XElement b= <span class="kwrd">new</span> XElement(<span class="str">"book"</span>, vL.FirstOrDefault().BookName);
            results.Add b
            <span class="kwrd">foreach</span> (var v <span class="kwrd">in</span> vL)
            {
                XElement v1 = <span class="kwrd">new</span> XElement(<span class="str">"verse"</span>,
                              <span class="kwrd">new</span> XElement(<span class="str">"chapter"</span>, v.Chapter),
                              <span class="kwrd">new</span> XElement(<span class="str">"verseNumber"</span>, v.VerseNumber),
                              <span class="kwrd">new</span> XElement(<span class="str">"verseText"</span>, v.Verse)
                     );
                results.Add v1
            }

            returnXML.Add(r);
            <span class="kwrd">return</span> returnXML;

        }</pre>
<p> </p>
<p>Noisy Comments:</p>
<p>We&#8217;ve all seen these comments, probably most of us are guilty of creating them.  Noisy comments are comments that serve no other purpose other than to repeat what has been stated in the code.  Comments should reveal intent that is not apparent in the code.</p>
<pre class="csharpcode"><span class="rem">/// RandomVerse</span>
<span class="rem">/// returns a random integer</span>
<span class="rem">/// uses no parameters</span>
<span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">int</span> RandomVerse()
{
    <span class="kwrd">return</span> GetRandomNumber(1, 30000);
}</pre>
<p> </p>
<p>Busy Methods:</p>
<p>Busy methods are those which do to much.  Methods need to follow the Single Responsibility Principle which says that a method should do one thing, do it well, and do only that one thing.  Well the SRP is commonly applied to Class&#8217;s but I think it fits Methods as well.</p>
<p>There are lots of articles, blogs, books on what dirty code looks like and what to do with it. </p>
<p><a href="http://www.codinghorror.com/">Coding Horror:</a><br />
Jeff Atwood has  quite a few good articles on the subject.</p>
<p><a title="http://www.codinghorror.com/blog/archives/000589.html" href="http://www.codinghorror.com/blog/archives/000589.html">Smelly Code</a></p>
<p><a title="http://www.codinghorror.com/blog/archives/000805.html" href="http://www.codinghorror.com/blog/archives/000805.html">Curly&#8217;s Law</a></p>
<p> </p>
<p><a href="http://blog.objectmentor.com/">Robert Martin (Uncle Bob)</a></p>
<p>Robert Martin has written a book on the subject of <a style="&quot;border:none" href="&lt;a href=&quot;http://www.amazon.com/gp/product/0132350882?ie=UTF8&amp;tag=isanl-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0132350882&quot;&gt;Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin Series)&lt;/a&gt;&lt;img src=">Clean Code</a>.  Which I highly recommend.</p>
<p> </p>
<p><strong>What to do with Dirty Code?</strong></p>
<p>Refactor!!!</p>
<p> </p>
<p>to be continued&#8230;</p>
<p> </p>
<p>David Yancey</p>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/DavidYancey?a=myY2Et48"><img src="http://feeds.feedburner.com/~f/DavidYancey?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DavidYancey?a=k01eKVtK"><img src="http://feeds.feedburner.com/~f/DavidYancey?i=k01eKVtK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DavidYancey?a=uKhv1vZj"><img src="http://feeds.feedburner.com/~f/DavidYancey?i=uKhv1vZj" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DavidYancey/~4/IhuG-Yvz9wI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-yancey.com/blog/index.php/2008/12/10/dirty-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.david-yancey.com/blog/index.php/2008/12/10/dirty-code/</feedburner:origLink></item>
		<item>
		<title>Refactoring: Getting started is the hard part</title>
		<link>http://feedproxy.google.com/~r/DavidYancey/~3/kZhW9s628iY/</link>
		<comments>http://www.david-yancey.com/blog/index.php/2008/11/25/refactoring-getting-started-is-the-hard-part/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 06:50:59 +0000</pubDate>
		<dc:creator>david.yancey</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.david-yancey.com/blog/index.php/2008/11/25/refactoring-getting-started-is-the-hard-part/</guid>
		<description><![CDATA[Just the thought of &#8216;refactoring&#8217; can be daunting to a programmer. 
Martin Fowler defines &#8216;refactoring&#8217; as:
Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. Its heart is a series of small behavior preserving transformations. Each transformation (called a &#8216;refactoring&#8217;) does little, but a sequence [...]]]></description>
			<content:encoded><![CDATA[<p>Just the thought of &#8216;refactoring&#8217; can be daunting to a programmer. </p>
<p><a href="http://www.refactoring.com/">Martin Fowler</a> defines &#8216;refactoring&#8217; as:</p>
<blockquote><p>Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. Its heart is a series of small behavior preserving transformations. Each transformation (called a &#8216;refactoring&#8217;) does little, but a sequence of transformations can produce a significant restructuring. Since each refactoring is small, it&#8217;s less likely to go wrong. The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring.</p></blockquote>
<p>When I first started to look at our library of Legacy Code my first thought was to just scrap the library and start over.  Now try to sell that idea to the stake holders.  Not going to happen is it.  So that&#8217;s where refactoring come&#8217;s in.  But there are a few obstacles we have to over come in this process.</p>
<ol>
<li><strong>Sell the process to the product owner/business:<br />
</strong><a href="http://www.jbrains.ca/">J.B Rainsburger</a> used an analogy that helps us with this obstacle.  The use of credit cards.  Each time we purchase an item with a credit card, we are purchasing that item with something we don&#8217;t have which is money.  Now let&#8217;s take this and apply it to programming against that library of legacy code.  Each time we do we are developing on credit and spending something we don&#8217;t have which is time.</li>
<li><strong>Single Methods with large amounts of code:</strong><br />
First let me refer you to an excellent book by <a href="http://www.objectmentor.com/omTeam/feathers_m.html">Michael Feathers</a> titled <a href="http://www.amazon.com/gp/product/0131177052?ie=UTF8&amp;tag=isanl-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0131177052">Working Effectively with Legacy Code</a><img style="margin: 0px; border-top-style: none! important; border-right-style: none! important; border-left-style: none! important; border-bottom-style: none! important" src="http://www.assoc-amazon.com/e/ir?t=isanl-20&amp;l=as2&amp;o=1&amp;a=0131177052" border="0" alt="" width="1" height="1" />.  In this book Michael suggests that we take that method and create a class with only that code.  With this class we can now start writing unit tests for the code and begin refactoring.  Now in our legacy code where we just pulled the large method from create a call to the method in our new class. </li>
<li><strong>Duplicate Code:<br />
</strong>“When N things need to change and N&gt;1, <a href="http://www.netobjectives.com/blogs/shalloways-law-and-shalloways-principle">Shalloway</a> will find at most N-1 of these things.”  Basically what Alan Shalloway is saying here is that if you have more than 1 duplication of code chances are high you won&#8217;t find all instances of that duplication.  This is where design patterns come in and the phrase &#8220;refactor to patterns&#8221;.</li>
<li><strong>Where do I start?:<br />
</strong>The hardest obstacle to overcome is where to start.  Practice</p>
<ul>
<li>Start off by finding a section of code that you feel may could use some refactoring. </li>
<li>Work on refactoring it for 30min.</li>
<li>Throw that code away. </li>
<li>Take a break</li>
<li>Repeat.</li>
</ul>
<p>&#8220;Throw away my code!!!&#8221; you might be saying to yourself right now. Yes, Throw it away. What this does for you is reminds you that you are just practicing and 2nd it separates you from your code.</li>
<li><strong>TDD and Refactoring?:</strong>  Yes its possible.  As you go through your refactoring you&#8217;ll see that you are refactoring to patterns, while you are doing this, ask yourself &#8220;how would I want to test this code?&#8221;  Retrain your way of thinking in how you approach code and you&#8217;ll soon find yourself refactoring through TDD and Design Patterns.</li>
</ol>
<p> </p>
<p>So there you have a few tips on how to overcome a few obstacles when you start to look at refactoring your legacy code for the first time.</p>
<p> </p>
<p>David Yancey</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/DavidYancey?a=W8kOeONt"><img src="http://feeds.feedburner.com/~f/DavidYancey?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DavidYancey?a=gb8RdzAv"><img src="http://feeds.feedburner.com/~f/DavidYancey?i=gb8RdzAv" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DavidYancey?a=NsVZqeFS"><img src="http://feeds.feedburner.com/~f/DavidYancey?i=NsVZqeFS" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DavidYancey/~4/kZhW9s628iY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-yancey.com/blog/index.php/2008/11/25/refactoring-getting-started-is-the-hard-part/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.david-yancey.com/blog/index.php/2008/11/25/refactoring-getting-started-is-the-hard-part/</feedburner:origLink></item>
		<item>
		<title>Agile and the .NET Community</title>
		<link>http://feedproxy.google.com/~r/DavidYancey/~3/TnMaPaHnRyo/</link>
		<comments>http://www.david-yancey.com/blog/index.php/2008/11/19/agile-and-the-net-community/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 05:08:18 +0000</pubDate>
		<dc:creator>david.yancey</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Agile]]></category>

		<guid isPermaLink="false">http://www.david-yancey.com/blog/index.php/2008/11/19/agile-and-the-net-community/</guid>
		<description><![CDATA[Why does it seem that the .NET Community isn&#8217;t very active in the Agile community?  I know that there are Agile practitioners in various .NET shops however, it seems that the overall representation is very minimal.  Is it because of a lack of understanding of the Agile methodologies? Or is there a lack of support [...]]]></description>
			<content:encoded><![CDATA[<p>Why does it seem that the .NET Community isn&#8217;t very active in the Agile community?  I know that there are Agile practitioners in various .NET shops however, it seems that the overall representation is very minimal.  Is it because of a lack of understanding of the Agile methodologies? Or is there a lack of support and resources for the .NET community when it comes to Agile practices?</p>
<p>I just got back from the <a href="http://www.sqe.com/agiledevpractices/">Agile Development Practices</a> by <a href="http://www.sqe.com">SQE</a> and I felt like I was in the minority there.  As I went from sessions on TDD to Design Patterns to Refactoring each time it was asked what platform each of the developers were on I was one of 2 or 3 that mentioned .NET.  The majority was Java with a small representation of Ruby developers, which on one hand I&#8217;m glad because I got a great exposure to Java and Ruby, however on the other hand it raises the questions as to why.</p>
<p>So what is Agile?</p>
<p><a href="http://www.agilemanifesto.org/">Agile Manifesto</a>:</p>
<blockquote><p><strong>Individuals and interactions</strong> over processes and tools<br />
<strong>Working software</strong> over comprehensive documentation<br />
<strong>Customer collaboration</strong> over contract negotiation<br />
<strong>Responding to change</strong> over following a plan</p>
<p>That is, while there is value in the items on<br />
the right, we value the items on the left more.</p></blockquote>
<p>Looking at the <a href="http://www.agilemanifesto.org/principles.html">principles behind the manifesto</a> we see more of what really is the driving force of the Agile movement and begin to understand why it is important to all developers to grasp this concept.</p>
<blockquote>
<ol>
<li>Our highest priority is to <strong>satisfy the customer</strong><br />
through <strong>early and continuous delivery</strong><br />
of valuable software.</li>
<li><strong>Welcome changing requirements</strong>, even late in<br />
development. Agile processes harness change for<br />
the <strong>customer&#8217;s competitive advantage</strong>.</li>
<li><strong>Deliver working software frequently</strong>, from a<br />
couple of weeks to a couple of months, with a<br />
preference to the shorter timescale.</li>
<li><strong>Business people and developers must work<br />
together</strong> daily throughout the project.</li>
<li><strong>Build projects around motivated individuals</strong>.<br />
Give them the environment and support they need,<br />
and trust them to get the job done.</li>
<li>The most efficient and effective method of<br />
conveying information to and within a development<br />
team is <strong>face-to-face conversation.</strong></li>
<li><strong>Working software is the primary measure of progress.</strong></li>
<li>Agile processes <strong>promote sustainable development</strong>.<br />
The sponsors, developers, and users should be able<br />
to maintain a constant pace indefinitely.</li>
<li><strong>Continuous attention to technical excellence<br />
and good design</strong> enhances agility.</li>
<li><strong>Simplicity</strong>&#8211;the art of maximizing the amount<br />
of work not done&#8211;is essential.</li>
<li>The best architectures, requirements, and designs<br />
emerge from<strong> self-organizing teams</strong>.</li>
<li>At regular intervals, the <strong>team reflects</strong> on how<br />
to become more effective, then tunes and adjusts<br />
its behavior accordingly.</li>
</ol>
</blockquote>
<p>The early continuous delivery of quality working software through continuous attention to simplicity, technical excellence, good design where the business and developers form a team to work together frequently reflecting how to become more effective through self organization.</p>
<p>This is just the beginning however, Agile goes beyond just what is stated in the manifesto.  There are methodologies for all aspects of the business, from the executives with <a href="http://www.poppendieck.com/">LEAN</a>, to the team with <a href="http://www.controlchaos.com/">SCRUM</a> down to the individual developers with <a href="http://www.extremeprogramming.org/rules.html">XP (Extreme Programming).</a>  Some of the concepts with in XP will be quite familiar to the .NET community, such as Test Driven Development (TDD) and Pair Programming. </p>
<p>I want to encourage all developers to really look into what Agile has to offer and then take it to your business and challenge them to implement Agile as your new methodology.  If you are already doing Agile then start speaking up about it.  Make your presence known and help evangelize Agile in the .NET community.</p>
<p> </p>
<p>David Yancey</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/DavidYancey?a=S9sshFZt"><img src="http://feeds.feedburner.com/~f/DavidYancey?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DavidYancey?a=vWV1M6i9"><img src="http://feeds.feedburner.com/~f/DavidYancey?i=vWV1M6i9" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DavidYancey?a=ZZbFHqnJ"><img src="http://feeds.feedburner.com/~f/DavidYancey?i=ZZbFHqnJ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DavidYancey/~4/TnMaPaHnRyo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-yancey.com/blog/index.php/2008/11/19/agile-and-the-net-community/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.david-yancey.com/blog/index.php/2008/11/19/agile-and-the-net-community/</feedburner:origLink></item>
	</channel>
</rss>
