<?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; ddd</title>
	<atom:link href="http://www.davidsantoro.net/?feed=rss2&#038;tag=ddd" 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>Value Objects rocks!</title>
		<link>http://www.davidsantoro.net/?p=44</link>
		<comments>http://www.davidsantoro.net/?p=44#comments</comments>
		<pubDate>Sat, 06 Mar 2010 21:41:38 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ddd]]></category>
		<category><![CDATA[object oriented programming]]></category>
		<category><![CDATA[ood]]></category>
		<category><![CDATA[value objects]]></category>

		<guid isPermaLink="false">http://www.davidsantoro.net/?p=44</guid>
		<description><![CDATA[For our book club in Ewloe we decided for a change to watch an infoq video. The team was showing an interest for DDD and few recent refactoring were towards encapsulation of logic in a few core Value Objects. Mike Wagg and Mark Needham suggested one of the talk they attended at QCon London 2009 [...]]]></description>
			<content:encoded><![CDATA[<p>For our book club in Ewloe we decided for a change to watch an infoq video.<br />
The team was showing an interest for DDD and few recent refactoring were towards encapsulation of logic in a few core Value Objects. Mike Wagg and Mark Needham suggested one of the talk they attended at QCon London 2009 <a href="http://www.infoq.com/presentations/Value-Objects-Dan-Bergh-Johnsson">Dan Bergh Johnsson value objects talk</a>.</p>
<p>Discussing the talk one question came out, &#8220;When do we introduce value objects, right from the beginning or when certain conditions arise?&#8221;</p>
<p>The agreed answer was to introduce them later by refactoring although I now feel that we should introduce them earlier for the following reasons:</p>
<ul>
<li>They become useful very quickly</li>
<li>They help express intent and help understand the domain</li>
<li>Having few examples of Value Objects in the code base helps new developers pick up good habits because they tend to copy from existing code at the beginning</li>
</ul>
<p>An interesting side effect of value objects&#8230; they make programmers happier! I saw smiles appear on the face of one pair of developers after they figure how value objects helped them avoid some dodgy code duplicated code in the view.</p>
<p>Another side effect of value objects is that they help you avoid null references by facilitating the introduction of Null Objects. </p>
<p>The only things that stops me to use value objects more is the friction that some tools like ORM cause. For example in order to have value objects field properly mapped using Hibernate it is necessary to implement a Custom User Type which can be an onerous an error prone operation.<br />
There is also a lack of refactoring tools that helps you encapsulating one or more fields in a composite object.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.davidsantoro.net%2F%3Fp%3D44&amp;linkname=Value%20Objects%20rocks%21"><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=44</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Budding off: Marking domain concepts in code</title>
		<link>http://www.davidsantoro.net/?p=28</link>
		<comments>http://www.davidsantoro.net/?p=28#comments</comments>
		<pubDate>Sun, 07 Feb 2010 14:58:01 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[ddd]]></category>
		<category><![CDATA[object oriented programming]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://www.davidsantoro.net/?p=28</guid>
		<description><![CDATA[The project I&#8217;m working on at the moment spins around one main domain concept. For the sake of the example I would use a class InvestmentFund. The initial approach to the design of the InvestmentFund object was quite rudimentary but unfortunately something not uncommon in our industry. Each field of the database table got mapped [...]]]></description>
			<content:encoded><![CDATA[<p>The project I&#8217;m working on at the moment spins around one main domain concept. For the sake of the example I would use a class InvestmentFund.<br />
The initial approach to the design of the InvestmentFund object was quite rudimentary but unfortunately something not uncommon in our industry.<br />
Each field of the database table got mapped to a field in the object and there is an abundance of primitive and nullable fields.</p>
<p>The InvestmentFund class looks a bit like the following but 10 times larger:<br />
<script src="http://gist.github.com/297969.js?file=gistfile1.cs"></script></p>
<p>I am trying to push the use of more granular and less primitive objects in our domain and I am promoting a refactoring of our core domain objects by following three ways suggested in the book <a href="http://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627">Growing Object Oriented Software Guided by Tests</a>:</p>
<ul>
<li><strong>Breaking out</strong> consists in splitting the responsibilities of large objects in several smaller ones.</li>
<li><strong>Budding off</strong> is used to mark domain concepts in code by creating objects that wrap fields or not fields at all.</li>
<li><strong>Bundling up</strong> consists in assembling in one object a group of values that are generally used together.</li>
</ul>
<p>A first refactoring <strong>bundled up</strong> together some of the values of InvestmentFund like the fees information. The result was a type Fee:</p>
<p><script src="http://gist.github.com/297484.js?file=gistfile1.cs"></script></p>
<p>which transformed our InvestmentFund class in:<br />
<script src="http://gist.github.com/297972.js?file=gistfile1.cs"></script></p>
<p>A second refactoring that I would like to pursue is a way to differentiate decimals that represent money and decimals that represent percentages. <strong>Budding off</strong> those type make sense but I am not sure of the best to model rates.<br />
Do I need a general Percentage type, a more specific InterestRate type or a type for each one of my rate types like &#8220;commission&#8221;?<br />
The latter looks a bit like what my collegue <a href="http://www.markhneedham.com/">Mark Needham</a> describes as a <a href="http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/">Micro-Type</a>.</p>
<p>I will probably start with the simplest solution (a Percentage type) and see how it goes.</p>
<p>Feedback is much appreciated. </p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.davidsantoro.net%2F%3Fp%3D28&amp;linkname=Budding%20off%3A%20Marking%20domain%20concepts%20in%20code"><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=28</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
