<?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/"
	>

<channel>
	<title>Evan Bottcher &#187; ThoughtWorks</title>
	<atom:link href="http://evan.bottch.com/category/thoughtworks/feed/" rel="self" type="application/rss+xml" />
	<link>http://evan.bottch.com</link>
	<description>// TODO: think of a witty and intelligent tagline</description>
	<pubDate>Tue, 03 Feb 2009 12:03:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setter injection sucks</title>
		<link>http://evan.bottch.com/2009/02/03/setter-injection-sucks/</link>
		<comments>http://evan.bottch.com/2009/02/03/setter-injection-sucks/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 12:03:00 +0000</pubDate>
		<dc:creator>evan</dc:creator>
		
		<category><![CDATA[Software]]></category>

		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://evan.bottch.com/?p=60</guid>
		<description><![CDATA[I know it&#8217;s not trendy to re-hash old java programming discussions - I should be discussing some new amazing functional language, however I&#8217;m in a grumpy mood.  I have a beef with what appears to be the dominant trend of using setter-based dependency injection.  I&#8217;m an old-skool dependency inject-er - I started with [...]]]></description>
			<content:encoded><![CDATA[<p>I know it&#8217;s not trendy to re-hash old java programming discussions - I should be discussing some new amazing functional language, however I&#8217;m in a grumpy mood.  I have a beef with what appears to be the dominant trend of using setter-based dependency injection.  I&#8217;m an old-skool dependency inject-er - I started with picocontainer when Spring was unheard of (well at least by me).  What I particularly like was the way it changed the way I <strong>designed</strong> my java code.  (For the spring-kiddies, PicoContainer *only* supported <a href="http://docs.codehaus.org/display/PICO/Constructor+Injection">constructor injection</a>)</p>
<p>A common complaint I hear about constructor injection is &#8220;I don&#8217;t like having so many constructor arguments&#8221;.  Yup this crossed my mind when I first came across it too - then it dawned on me:  perhaps having too many dependencies injected into a class is a code smell?  How many other classes should this class be collaborating with?  Am I missing an abstraction in my model?  Many times I&#8217;ve looked at a class and simply by looking at it&#8217;s constructor signature I&#8217;ve had a nagging doubt about it&#8217;s hygiene.</p>
<p>A big reason I prefer constructor injection is that I can ensure that when an object is constructed is ready to do it&#8217;s job.  I do not have to concern myself with whether the class has been &#8216;wired&#8217; correctly in configuration and that all dependencies have been met.  If I introduce a new dependency, I can find all places in the code (and pretty quickly in configuration) where I&#8217;ve caused a breakage.</p>
<p>However it&#8217;s now 2009 and I&#8217;m still (occasionally) writing java, but pretty regularly I&#8217;m in a team that has settled on setter injection as a standard.  It&#8217;s the default option in the Rod Johnson scriptures I guess.  I also believe in most cases it&#8217;s better to be consistent than argue what some see as a fine point, so again I fall into line and am forced to use setter injection.  But I do want to bitch about it.</p>
<p>How about this test setup code:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">        WidgetGetter widgetGetter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WidgetGetter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        widgetGetter.<span style="color: #006633;">setHttpClient</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> HttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        WeeResourceFactory resourceFactory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WeeResourceFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        resourceFactory.<span style="color: #006633;">setWidgetGetter</span><span style="color: #009900;">&#40;</span>widgetGetter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        resourceFactory.<span style="color: #006633;">setSomeParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;the quick brown fox&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        FooRepository repo <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FooRepository<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        repo.<span style="color: #006633;">setBarFactory</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> BarFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        repo.<span style="color: #006633;">setResourceFactory</span><span style="color: #009900;">&#40;</span>resourceFactory<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>versus this?:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">        WidgetGetter widgetGetter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WidgetGetter<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> HttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        WeeResourceFactory resourceFactory <span style="color: #339933;">=</span> 
            <span style="color: #000000; font-weight: bold;">new</span> WeeResourceFactory<span style="color: #009900;">&#40;</span>widgetGetter, <span style="color: #0000ff;">&quot;the quick brown fox&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        FooRepository repo <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FooRepository<span style="color: #009900;">&#40;</span>resourceFactory, <span style="color: #000000; font-weight: bold;">new</span> BarFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I&#8217;m also into configuration in code rather than in XML, but I worry I&#8217;ll get burned at the stake if I bring <strong>THAT</strong> up again.</p>
]]></content:encoded>
			<wfw:commentRss>http://evan.bottch.com/2009/02/03/setter-injection-sucks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Danger Will Robinson</title>
		<link>http://evan.bottch.com/2008/07/26/danger-will-robinson/</link>
		<comments>http://evan.bottch.com/2008/07/26/danger-will-robinson/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 11:37:19 +0000</pubDate>
		<dc:creator>evan</dc:creator>
		
		<category><![CDATA[Tech]]></category>

		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://evan.bottch.com/?p=57</guid>
		<description><![CDATA[I wrote my previous post about running linux on my desktop a couple of weeks back and realise I didn&#8217;t put a disclaimer on the post, so here it is&#8230;
IF IT ALL GOES HORRIBLY WRONG DON&#8217;T BLAME ME!
What I didn&#8217;t mention in my post is that the first time I installed vmware and loaded up [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote my <a href="http://evan.bottch.com/2008/07/12/linux-at-work-again/">previous post</a> about running linux on my desktop a couple of weeks back and realise I didn&#8217;t put a disclaimer on the post, so here it is&#8230;</p>
<p>IF IT ALL GOES HORRIBLY WRONG DON&#8217;T BLAME ME!</p>
<p>What I didn&#8217;t mention in my post is that the first time I installed vmware and loaded up the windows partition it worked great.  Then I was tooling about in windows (I think uninstalling some cruft) and it required a reboot.  No worries, but then my attention drifted and I went off to another desktop on the linux host.  When I looked back a few minutes later I realised in great horror that the vm had automatically booted via GRUB into the ubuntu partition.  I was looking at the ubuntu login screen, in a vm running on the same ubuntu install.  Nasty feeling.  Power off button on the VM.</p>
<p>Too late - everything in the running host OS started to unravel and I quickly crashed and burned.  Someone in the audience will probably pipe up at this point and say &#8220;you could have recovered by xyz&#8221; but after a couple of people had a poke around with no success I took the quick route and reinstalled ubuntu again.</p>
<p>Not recommended&#8230;</p>
<p>Luckily the windows partition was untouched.</p>
]]></content:encoded>
			<wfw:commentRss>http://evan.bottch.com/2008/07/26/danger-will-robinson/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Linux at work again!</title>
		<link>http://evan.bottch.com/2008/07/12/linux-at-work-again/</link>
		<comments>http://evan.bottch.com/2008/07/12/linux-at-work-again/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 11:19:36 +0000</pubDate>
		<dc:creator>evan</dc:creator>
		
		<category><![CDATA[Brainfart]]></category>

		<category><![CDATA[Tech]]></category>

		<category><![CDATA[ThoughtWorks]]></category>

		<category><![CDATA[LinkedIn]]></category>

		<guid isPermaLink="false">http://evan.bottch.com/?p=56</guid>
		<description><![CDATA[For the past couple of months I&#8217;ve been working in a very nice workplace with a bunch of nice people and even better some of them run Linux on their desktops without any fear of the SOE-police coming to march them out of the building! I&#8217;m also working again with a chap who despite an [...]]]></description>
			<content:encoded><![CDATA[<p>For the past couple of months I&#8217;ve been working in a very nice workplace with a bunch of nice people and even better some of them run Linux on their desktops without any fear of the <abbr title="Standard Operating environment">SOE</abbr>-police coming to march them out of the building! I&#8217;m also working again with a <a href="http://www.mojain.com.au/michael/resume">chap</a> who despite an unnatural love of emacs is a great help at solving any problems I face running Linux at work.  So off I set to install Ubuntu Hardy on the client desktop - with their blessing!</p>
<p>I love Linux (and particularly Ubuntu) as a working environment.  Most of the applications I&#8217;ve worked on in the last 10 years have been deployed on a flavour of unix, and despite doing a lot of Java I also do a lot of scripting and glue code, build and deployment tooling in particular.  Working on Windows even with cygwin is just a world of pain.</p>
<p>Unfortunately I&#8217;m not able to avoid Microsoft Outlook *sigh*.  I spend more time in meetings than I care to admit, and I regularly have to set up meetings with invitees and meeting room resources.  Webmail doesn&#8217;t cut it.  Evolution really doesn&#8217;t cut it for much more than reading mail - even sending mail it&#8217;s a bit flakey.  Great effort, I really hope one day someone gets involved who can make it stable.</p>
<p>So what I and some others are doing is running VMWare Server under Ubuntu, booting the <span style="text-decoration: underline;">physical Windows partition</span> from disk.  When I installed Ubuntu I resized the existing single partition and left the client SOE Windows installation fully functional.  It works incredibly well booted under VMWare once everything is loaded - we run Outlook 2007 which is slow as a dog even non-virtualized - and I&#8217;m never going to look back.  The best part is if I ever NEED to I can boot the same partition directly.</p>
<p>It&#8217;s a little tricky getting VMWare Server to run on Ubuntu, as you have to apply a patch (vmware-any-any) to make it install.  I followed the instructions here on <a href="http://www.howtoforge.com/ubuntu_feisty_fawn_vmware_server_howto">howtoforge</a>, and they worked on Hardy.  I found I had to run vmware-config.pl twice - once when the patch is applied, and then once more to make it work properly.</p>
<p>Once VMWare is installed it is important to boot under Windows directly, and set up a new hardware profile for &#8220;virtual boot&#8221;.  When you boot Windows under VMWare the first time, choose the virtual boot profile.  It will detect a bunch of new VMWare hardware, which will then be associated with the virtual boot profile.  This means when you boot directly for some reason later, you can choose the default boot profile and everything will work as it always did.</p>
<p>I&#8217;m stoked at how well this works.  I have VMWare tools installed so that it gives focus to Windows when I move my mouse over the VMWare window (no Ctrl-Alt-Esc).  Highly recommended.</p>
]]></content:encoded>
			<wfw:commentRss>http://evan.bottch.com/2008/07/12/linux-at-work-again/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Distracted</title>
		<link>http://evan.bottch.com/2008/07/12/distracted/</link>
		<comments>http://evan.bottch.com/2008/07/12/distracted/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 10:50:29 +0000</pubDate>
		<dc:creator>evan</dc:creator>
		
		<category><![CDATA[Brainfart]]></category>

		<category><![CDATA[Tech]]></category>

		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://evan.bottch.com/?p=55</guid>
		<description><![CDATA[Whenever I think I&#8217;ll write a blog post, I get as far as logging into my wordpress admin and it&#8217;s always the case that a new version of wordpress has been released and it nags me to upgrade.  Ooh I think and head off down a nice little alleyway of distraction.  I usually take a [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I think I&#8217;ll write a blog post, I get as far as logging into my wordpress admin and it&#8217;s always the case that a new version of wordpress has been released and it nags me to upgrade.  Ooh I think and head off down a nice little alleyway of distraction.  I usually take a few minutes to remember my username/password for my hosting provider, upload and unpack files yada yada.  That normally takes care of my urge to write a blog post&#8230;</p>
<p>I&#8217;m frighteningly similar when it comes to writing code on my desktop machine at home - of course there are 227 incoming critical updates from ubuntu.  Or maybe I need to upgrade from Hefty to Iggy (or whatever).  Of course my Eclipse is 3 versions out of date, and I couldn&#8217;t possibly use that Java version (or ruby or pascal, or whatever it is I use these days).  By the time I get everything up to date I&#8217;ve usually forgotten what it was I came upstairs to work on anyway.</p>
<p>They&#8217;re my habits and I love them.</p>
]]></content:encoded>
			<wfw:commentRss>http://evan.bottch.com/2008/07/12/distracted/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BarCamping (without the actual camping part)</title>
		<link>http://evan.bottch.com/2008/02/24/barcamping-without-the-actual-camping-part/</link>
		<comments>http://evan.bottch.com/2008/02/24/barcamping-without-the-actual-camping-part/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 13:26:40 +0000</pubDate>
		<dc:creator>evan</dc:creator>
		
		<category><![CDATA[Software]]></category>

		<category><![CDATA[Tech]]></category>

		<category><![CDATA[ThoughtWorks]]></category>

		<category><![CDATA[BarCamp]]></category>

		<category><![CDATA[BarCampMelbourne2008]]></category>

		<guid isPermaLink="false">http://evan.bottch.com/2008/02/24/barcamping-without-the-actual-camping-part/</guid>
		<description><![CDATA[I attended my first BarCamp today and I was really impressed.  It was a very full day of interesting presentations by a lot of very smart people, the range of topics was really quite startling.  I&#8217;m familiar with user groups (although I don&#8217;t go along to as many nights as I&#8217;d like) and [...]]]></description>
			<content:encoded><![CDATA[<p>I attended my first <a href="http://barcampmelbourne.org/">BarCamp</a> today and I was really impressed.  It was a very full day of interesting presentations by a lot of very smart people, the <a href="http://barcampmelbourne.org/schedule/">range of topics</a> was really quite startling.  I&#8217;m familiar with user groups (although I don&#8217;t go along to as many nights as I&#8217;d like) and they tend to be quite focussed, however today people talked about whatever their current interest is - from Perl 5.1 to hardware devices to MythTV.  I was particularly impressed with the support and encouragement attendees gave to speakers.  If you&#8217;ve never given a public presentation and you&#8217;re unsure of yourself today would have been an excellent opportunity.</p>
<p>Like at user group nights and conferences I&#8217;m awkwardly shy and awful at striking conversation so I missed talking to a lot of interesting people today.  It&#8217;s a different mix of people than I&#8217;m used to (like the <a href="http://groups.google.com/group/melbourne-ruby">Ruby user group</a>) with a slant towards freelancing and smaller projects which is so refreshing compared to the behemoth corporate beasts I&#8217;m more familiar with these days.</p>
<p>Favorite presentations today: Mark Ryall&#8217;s Intro to Scala (second time around), and Paul Fenwick on an Illustrated History of Failure (with sound effects).</p>
<p>I winged a short demo of the Rspec Story Framework which is my current shiny-toy-of-the-week.  I might have been better placed to answer questions if I&#8217;d actually used it in the wild yet&#8230;</p>
<p>Don&#8217;t miss BarCamp Melbourne 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://evan.bottch.com/2008/02/24/barcamping-without-the-actual-camping-part/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Subdirectory</title>
		<link>http://evan.bottch.com/2007/12/10/subdirectory/</link>
		<comments>http://evan.bottch.com/2007/12/10/subdirectory/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 01:13:28 +0000</pubDate>
		<dc:creator>evan</dc:creator>
		
		<category><![CDATA[Brainfart]]></category>

		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://evan.bottch.com/2007/12/10/subdirectory/</guid>
		<description><![CDATA[Bob Martin:
At the ER they put me in a room and gave me a dose of Morphine. Morphine is a very nice drug. It had the effect of filing the pain away in a convenient subdirectory where I could access it if I needed it, but was otherwise out of the way.
Brilliant description.  I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.objectmentor.com/articles/2007/12/07/thinking-about-an-appendix">Bob Martin</a>:</p>
<blockquote><p>At the ER they put me in a room and gave me a dose of Morphine. Morphine is a very nice drug. It had the effect of filing the pain away in a convenient subdirectory where I could access it if I needed it, but was otherwise out of the way.</p></blockquote>
<p>Brilliant description.  I recently had a healthy diet of Morphine for a couple of days (followed by a few more days of oxynorm, which is similar).  After my first dose of Morphine the emergency doctor came to see me and I couldn&#8217;t help grinning like a loony, despite the horror of my injury.  Good stuff when you need it.</p>
]]></content:encoded>
			<wfw:commentRss>http://evan.bottch.com/2007/12/10/subdirectory/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Factory and Repository in the Domain</title>
		<link>http://evan.bottch.com/2007/12/06/factory-and-repository-in-the-domain/</link>
		<comments>http://evan.bottch.com/2007/12/06/factory-and-repository-in-the-domain/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 10:32:00 +0000</pubDate>
		<dc:creator>evan</dc:creator>
		
		<category><![CDATA[Software]]></category>

		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://evan.bottch.com/2007/12/06/factory-and-repository-in-the-domain/</guid>
		<description><![CDATA[I&#8217;m a big fan of the book Domain Driven Design, and for some time I&#8217;ve been pushing the principles and patterns in my workplace.  I&#8217;ve never managed to get &#8216;into&#8217; the more theoretical parts of the book, and I chuckle each time one of my colleagues refers to the &#8220;contours of the domain&#8221;, however [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a big fan of the book <a href="http://www.itbooksonline.com.au/catalogue/category36/product576" target="_blank">Domain Driven Design</a>, and for some time I&#8217;ve been pushing the principles and patterns in my workplace.  I&#8217;ve never managed to get &#8216;into&#8217; the more theoretical parts of the book, and I chuckle each time one of my colleagues refers to the &#8220;contours of the domain&#8221;, however it&#8217;s up there with books that have caused a substantial shift in my thinking.</p>
<p>When I&#8217;m evangelising the use of Entities, Aggregates, Value Objects, and Repositories, one question that comes up regularly is &#8220;what&#8217;s the difference between a Repository and a plain old DAO?&#8221;.  It&#8217;s a very good question with the right level of skepticism.</p>
<p>I really enjoyed reading Christian Bauer&#8217;s post &#8220;<a href="http://in.relation.to/Bloggers/RepositoryPatternVsTransparentPersistence">Repository Pattern vs. Transparent Persistence</a>&#8221; - particularly the title which implies that there is a <strong>choice</strong> to be made between two approaches.  In actual fact transparent persistence as implemented in Hibernate makes DDD and the use of Repositories extremely powerful.  I&#8217;ll backtrack a little&#8230;</p>
<p>A lot of web application code that I find these days that was written with &#8216;best practice&#8217; of just a few years ago follows a rough outline like this.  DAO objects (or Data Mappers) provide find/save/update/delete operations  methods for each object in your domain.  The DAO is a basic abstraction around database persistence, often JDBC.</p>
<p>Business logic is usually either written directly within Transaction Scripts (recently I&#8217;ve become used to inheriting hundreds of lines of code in Struts actions&#8230; *sigh*) or within a basic Service Layer.  The script or service is the only thing that can hold references to the DAOs, so of course you HAVE to put the business logic there - in most web apps there is a lot of creation and persistence of objects.   No problem, we&#8217;ll just divide and conquer - from our scripts we&#8217;ll extract services, then we&#8217;ll divide our services into more services and delegate between them.</p>
<p>Because the application does a lot of operations requiring persistence, there&#8217;s a natural force preventing any business logic being moved to anywhere but scripts or service layers.  So what are our domain object?  Nothing but structures carrying data, with maybe some rudimentary logic that only affect local state.  The client code asks the domain to provide it with data, and then the client code makes decisions based on that data.</p>
<p>The transaction script and service layer approach is simple to begin with, but as the application becomes more complex it leads to a bunch of problems, especially as developers try to avoid duplication (cut and paste is bad kiddies).  Ever picked up a hierarchy of Struts actions seven layers deep with multiple Template Methods to allow overrides for different sub-classes?  Bloody nightmare.</p>
<p>What I&#8217;ve achieved by applying the DDD patterns is the elimination of those transaction scripts and  (most) services.  The transaction script (e.g. struts action in a web application if you&#8217;re so inclined) is simply responsible for <strong>finding an appropriate entry-point into the domain, then telling that domain class to do some work</strong>.</p>
<p>The consequence is that business logic can be expressed more deeply in your domain, you are free to find the right abstractions that will allow you to make your code understandable, and to create small classes with single responsibilities.  This also means that the creation and persistence of objects will be deep in the bowels of the domain, and even better - without the calling client code or script HAVING to be aware of the object creation.  How can this be?  Domain classes aren&#8217;t allowed to hold references to DAOs - that would break our traditional view of layering.</p>
<p>But&#8230; when I apply DDD, Repository and Factory interfaces are <strong>part of the domain</strong>.  This is a fundamental change - that a domain object deep in an aggregate can be constructed with a reference to a Repository in order to look up persistent data.  That a domain object can also use a Factory to construct objects, hiding the detail of construction (and dependency injection).  None of this work has to be done in a transaction script or script - move that responsibility into a place in your domain where it makes sense.</p>
<p>Repositories can be used to perform lazy instantiation of relationships in a persistent graph of domain objects.  E.g. retrieve a PurchaseOrder from the PurchaseOrderRepository, when the PurchaseOrder requires it&#8217;s line items it asks the LineItemRepository for matching line items.  A consequence is that this will lead to a bunch of Repositories being created in a complex model.  It&#8217;s simpler (less code) if you can use a tool like Hibernate to manage persistence of the entire graph, and configure it to automatically instantiate collection relationships lazily.  Nothing about Repository prevents you from doing that - you would just eliminate the use of Repository at that point and use the collection directly.   Hibernate is no solution to fit all problems however, and we commonly find places where explicit use of a Repository is cleaner.</p>
<p>I also deal with a lot of &#8216;legacy&#8217; code that needs to be renovated into submission - often a safe path with JDBC code is to refactor towards the use of Repositories and moving the use of those Repositories into the domain to make it more understandable.  Often the JDBC code inside the Repository implementation does not have to change much.  When it does later on, you have the opportunity to make a shift towards a technology like Hibernate.</p>
<p>Transparent persistence and the Hibernate Session is a really important tool for implementing a rich domain model - if we make our client code (transaction script, service) as thin as possible, it is no longer responsible for remembering which objects have been updated and saving them back to the database.  Instead we use the Hibernate Session as a <a href="http://martinfowler.com/eaaCatalog/unitOfWork.html">Unit of Work</a> - our client code tells the domain to go and do something and the domain can go ahead and perform calculations, validate data, and update fields as need be.  When the work is complete we tell the Session to commit and it works out what needs to be updated in the database.  Brilliant - now if we add more complexity to the domain we don&#8217;t have to add matching complexity to our client code, and not in multiple places.</p>
<p>Christian is very concerned with adding additional layers into our code - a Repository wrapping a DAO.  I personally do away with the DAO idea altogether - the Repository implementation is performing the same thing.  The important thing is that the Repository interface (e.g. PurchaseOrderRepository) lives in the domain, and the implementation (e.g. JdbcPurchaseOrderRepository or HibernatePurchaseOrderRepository) lives outside the domain in infrastructure.</p>
<p>Conclusion (otherwise I&#8217;ll go on all day):  let go of the idea that domain classes must not interact with a database (or a message queue or a file system) - free them to do their responsibility, just make sure they do so through an appropriate domain abstraction - Repository and Factory are good examples.</p>
<p>Oh - and stop using Struts (1.x anyway).</p>
]]></content:encoded>
			<wfw:commentRss>http://evan.bottch.com/2007/12/06/factory-and-repository-in-the-domain/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Exposed</title>
		<link>http://evan.bottch.com/2007/07/15/exposed/</link>
		<comments>http://evan.bottch.com/2007/07/15/exposed/#comments</comments>
		<pubDate>Sun, 15 Jul 2007 03:46:45 +0000</pubDate>
		<dc:creator>evan</dc:creator>
		
		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://evan.bottch.com/2007/07/15/exposed/</guid>
		<description><![CDATA[My colleague Mark thinks that no-one reads his blog.
]]></description>
			<content:encoded><![CDATA[<p>My colleague Mark thinks that no-one reads his <a href="http://manwithtwobrians.blogspot.com/2007/07/self-stalking.html">blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://evan.bottch.com/2007/07/15/exposed/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Australian Architecture Forum Done.</title>
		<link>http://evan.bottch.com/2007/07/04/australian-architecture-forum-done/</link>
		<comments>http://evan.bottch.com/2007/07/04/australian-architecture-forum-done/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 13:35:47 +0000</pubDate>
		<dc:creator>evan</dc:creator>
		
		<category><![CDATA[Software]]></category>

		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://evan.bottch.com/2007/07/04/australian-architecture-forum-done/</guid>
		<description><![CDATA[Last week I presented with some ThoughtWorks colleagues at the Australian Architecture Forum in Sydney and Melbourne.  My topic was titled &#8220;No Nukes - don&#8217;t detonate your legacy software&#8221; covering approaches to incrementally replacing a legacy application.  I was a bit shakey in Sydney - I&#8217;m not very comfortable with public speaking - [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I presented with some ThoughtWorks colleagues at the <a href="http://www.architectureforum.net.au/Pages/aaf.aspx">Australian Architecture Forum</a> in Sydney and Melbourne.  My topic was titled &#8220;No Nukes - don&#8217;t detonate your legacy software&#8221; covering approaches to incrementally replacing a legacy application.  I was a bit shakey in Sydney - I&#8217;m not very comfortable with public speaking - but I felt much better about my delivery in Melbourne.  All round a really great experience and I hope to do more of this kind of thing in the future.  The topic definitely sparked some interesting conversations - maintaining and renovating legacy applications (sometimes not more than 18 months old&#8230;) is such a big part of what we do as an industry.</p>
<p>The forum itself was mostly interesting - I don&#8217;t really identify well with the title &#8220;Architect&#8221; although that is a large part of the work that I do.  I find that most software architects seem to struggle to remain relevant as they get further divorced from project delivery.  For this reason I found my colleague Gianny Damour&#8217;s discussion group on &#8220;The role of the architect on agile projects&#8221; most entertaining as he described architectural practices found to be questionable including &#8220;pretentious modelling&#8221;, &#8220;over technical design&#8221; and &#8220;ivory tower mentality&#8221;.  It definitely sparked a healthy debate, especially the assertion that architects should code.</p>
<p>Much less amusing was a discussion group by the local chapter of the <a href="http://www.iasahome.org">International Association of Software Architects</a> that was preaching _certification_ as the answer to peer recognition of your mad architecting skillz.  That and several hundred pages of an &#8220;IT architect skills library&#8221;.  I think the secret architect handshake is detailed in UML 2.0 on page 259.  Forgive my skepticism.</p>
<p>Overall though a successful forum - congratulations to the organisers!</p>
]]></content:encoded>
			<wfw:commentRss>http://evan.bottch.com/2007/07/04/australian-architecture-forum-done/feed/</wfw:commentRss>
		</item>
		<item>
		<title>iPhone envy</title>
		<link>http://evan.bottch.com/2007/07/02/iphone-envy/</link>
		<comments>http://evan.bottch.com/2007/07/02/iphone-envy/#comments</comments>
		<pubDate>Sun, 01 Jul 2007 23:03:35 +0000</pubDate>
		<dc:creator>evan</dc:creator>
		
		<category><![CDATA[Tech]]></category>

		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://evan.bottch.com/2007/07/02/iphone-envy/</guid>
		<description><![CDATA[12 new posts on ThoughtBlogs this morning, and about 10 of them were about the iPhone.  No iPhone joy for the antipodes.  *sigh*
]]></description>
			<content:encoded><![CDATA[<p>12 new posts on <a href="http://blogs.thoughtworks.com/">ThoughtBlogs</a> this morning, and about 10 of them were about the iPhone.  No iPhone joy for the antipodes.  *sigh*</p>
]]></content:encoded>
			<wfw:commentRss>http://evan.bottch.com/2007/07/02/iphone-envy/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
