<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>David Santoro &#187; refactoring</title>
	<atom:link href="http://www.davidsantoro.net/?feed=rss2&#038;tag=refactoring" rel="self" type="application/rss+xml" />
	<link>http://www.davidsantoro.net</link>
	<description>Just another blog on software development experiences...</description>
	<lastBuildDate>Mon, 08 Mar 2010 07:18:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Refactoring Ruby Edition Chapter 2: Principles in Refactoring</title>
		<link>http://www.davidsantoro.net/?p=52</link>
		<comments>http://www.davidsantoro.net/?p=52#comments</comments>
		<pubDate>Sun, 07 Mar 2010 18:03:23 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ddd]]></category>
		<category><![CDATA[extreme programming]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.davidsantoro.net/?p=52</guid>
		<description><![CDATA[I have read the original Refactoring back in 2006 but I didn&#8217;t own a copy so due to my infatuation for the Ruby programming language I decided to buy a copy of Refactoring Ruby Edition. The first chapter introduce refactoring through a vert explicative example. The second chapter explore the core principles and origins of [...]]]></description>
			<content:encoded><![CDATA[<p>I have read the original Refactoring back in 2006 but I didn&#8217;t own a copy so due to my infatuation for the Ruby programming language I decided to buy a copy of Refactoring Ruby Edition.<br />
The first chapter introduce refactoring through a vert explicative example.<br />
The second chapter explore the core principles and origins of refactoring.  </p>
<p>It is interesting how refactoring is one of the core practices that Kent Beck and Ward Cunningham used on the famous C3 project and that then became part of the arsenal of the extreme programming&#8217;s practices.</p>
<p>Due to the iterative nature of extreme programming, a big up front design is unfeasible. Refactoring, unit testing and good object oriented practices allow to have a code that is easy, cheap and safe to change.</p>
<p>An another important point discussed in this chapter is when to refactor. The answer suggested is very similar to what I practice daily:</p>
<ul>
<li>Refactor when it helps to introduce a new feature</li>
<li>Refactor when fixing a bug</li>
<li>Refactor for better understanding</li>
</ul>
<p>The most valuable tip is the rule of 3:</p>
<p><quote>The first time, you just do something. The second time, you do something similar you wince at the duplication but you do it anyway. The third time, you refactor.</quote></p>
<p>One last point touched in the chapter was the impact of refactoring on software performance. There are several refactorings (e.g. Remove Temp with Query) that hinder performance. Martin Fowler states that ad hoc and localized performance improvement are expensive and sometimes counterproductive. We should always remember to make the software right and easy to change so that we can improve performance later where the bottlenecks lie. I think this seek for performance everywhere is a cognitive bias that we inherited from the time when developers had to deal with few Ks of memory and expensive processor time.</p>
<p>So far Refactoring Ruby Edition has been enjoyable and I&#8217;m looking forward to learn how to refactor in a more disciplined and cautious way.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.davidsantoro.net%2F%3Fp%3D52&amp;linkname=Refactoring%20Ruby%20Edition%20Chapter%202%3A%20Principles%20in%20Refactoring"><img src="http://www.davidsantoro.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.davidsantoro.net/?feed=rss2&amp;p=52</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TDD: When does &#8216;Good Enough Code&#8217; become not good enough?</title>
		<link>http://www.davidsantoro.net/?p=16</link>
		<comments>http://www.davidsantoro.net/?p=16#comments</comments>
		<pubDate>Mon, 25 Jan 2010 21:47:49 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[software craftmanship]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://www.davidsantoro.net/?p=16</guid>
		<description><![CDATA[Today I started try to refactor a piece of code that was causing me pain. Dependencies were tangled together, classes were getting bigger, functions and names were losing their meaning and unit tests were becoming cluttered and hard to understand. After few hours trying to tangle this code I started thinking that probably it would [...]]]></description>
			<content:encoded><![CDATA[<p>Today I started try to refactor a piece of code that was causing me pain.<br />
Dependencies were tangled together, classes were getting bigger, functions and names were losing their meaning and unit tests were becoming cluttered and hard to understand.<br />
After few hours trying to tangle this code I started thinking that probably it would have been easier if we had tackled that a few features earlier.<br />
When you are caught in the TDD cycle red &#8211; green &#8211; refactor it&#8217;s easy to focus only on small scale refactoring and losing the big picture. Also Bob Martin rule: &#8220;You may not write more production code than is sufficient to pass the current failing test.&#8221; might be misleading.<br />
Dan North talks of &#8220;&#8230;deferring important architectural and design decisions until the last responsible moment&#8221;.<br />
Is there an easy way to identify the last responsible moment?<br />
I think for now on I will stick to this rule: as soon as I start adding a feature to a piece of code I will make sure that it respect fundamentals good practices (small functions that do one thing, command query separation, small classes that follows the single responsibility principle and meaningful names). I will applly the same treatment to tests.<br />
I will probably spend more time caring about exception handling, good object modeling and so on, on the most used and strategic part of a codebase.<br />
In order to identify those areas, keeping track on stories that takes longer than expected and the one with more bugs, might help.<br />
What is your approach to this problem?</p>
<p>In the meanwhile you should follow me on twitter <a href="http://www.twitter.com/soulnafein">here</a> </p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.davidsantoro.net%2F%3Fp%3D16&amp;linkname=TDD%3A%20When%20does%20%26%238216%3BGood%20Enough%20Code%26%238217%3B%20become%20not%20good%20enough%3F"><img src="http://www.davidsantoro.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.davidsantoro.net/?feed=rss2&amp;p=16</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
