<?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>Substance of Code &#187; Design</title>
	<atom:link href="http://www.substanceofcode.com/category/design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.substanceofcode.com</link>
	<description>Software Artisan Tommi Laukkanen</description>
	<lastBuildDate>Mon, 06 Sep 2010 20:47:28 +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>From Anemic to Rich Domain Model</title>
		<link>http://www.substanceofcode.com/2007/01/17/from-anemic-to-rich-domain-model/</link>
		<comments>http://www.substanceofcode.com/2007/01/17/from-anemic-to-rich-domain-model/#comments</comments>
		<pubDate>Wed, 17 Jan 2007 19:15:52 +0000</pubDate>
		<dc:creator>Tommi Laukkanen</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.substanceofcode.com/2007/01/17/from-anemic-to-rich-domain-model/</guid>
		<description><![CDATA[I’ve been researching this subject lately since I’ve had many good conversations about the two approaches with my fellow co-workers. The Fowler’s term, Anemic Domain Model, was new to me even though I’ve used the both Rich and Anemic Domain &#8230; <a href="http://www.substanceofcode.com/2007/01/17/from-anemic-to-rich-domain-model/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I’ve been researching this subject lately since I’ve had many good conversations about the two approaches with my fellow co-workers. The Fowler’s term, Anemic Domain Model, was new to me even though I’ve used the both Rich and Anemic Domain Models in the past without giving much attention to the differences between these two approaches.</p>
<p>What is the difference between the Rich and Anemic Domain Models? I think that Martin Fowler describes this quite well in his blog post, <a href="http://www.martinfowler.com/bliki/AnemicDomainModel.html" onclick="pageTracker._trackPageview('/outgoing/www.martinfowler.com/bliki/AnemicDomainModel.html?referer=');">AnemicDomainModel</a> in 2003. Frans Bouma have also made a great posts about the different approaches. And in <a href="http://weblogs.asp.net/fbouma/archive/2004/10/09/240225.aspx" onclick="pageTracker._trackPageview('/outgoing/weblogs.asp.net/fbouma/archive/2004/10/09/240225.aspx?referer=');">this post</a> he describes quite well the differences between Entity Approach (Anemic Domain Model) and Domain Approach (Rich Domain Model). Here is my version of describing the difference between these two with simple UML diagram:</p>
<p><img title="Anemic and Rich Domain Models in UML" id="image126" alt="Anemic and Rich Domain Models in UML" src="http://www.substanceofcode.com/wp-content/uploads/2007/01/anemic-and-rich-domain-models.jpg" /></p>
<p>Basic idea in Rich Domain Model is that the <strong>behavior is included in the domain object</strong> compared to Anemic Domain Model where <strong>behavior is implemented in separate classes</strong>. This will reduce the lines-of-code in the application layer and it also makes the application code more maintainable since the use of domain objects is more logical.</p>
<p>Fowler wonders in his post why this anti-pattern, Anemic Domain Model, is still so common nowadays and one reason that comes to mind is that the existing applications, especially enterprise level applications, have used this approach as de facto through decades. This might also be the reason for even the Wikipedia’s <a href="http://en.wikipedia.org/wiki/Anemic_Domain_Model" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Anemic_Domain_Model?referer=');">article</a> to mention that some <a href="http://blog.springframework.com/arjen/archives/2006/10/10/domain-drivel/" onclick="pageTracker._trackPageview('/outgoing/blog.springframework.com/arjen/archives/2006/10/10/domain-drivel/?referer=');">argue</a> that this wouldn’t be anti-pattern at all. It feels like this subject divides developers to two camps in the same manner like different development platforms or operating systems.</p>
<p>Also the fact that this anti-pattern is used widely in the literature doesn’t help to adapt to the Rich Domain Model approach. I found a good example of this as I read the excellent book <a href="http://www.amazon.co.uk/gp/product/0672328968?ie=UTF8&#038;tag=subsofcode-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=0672328968" onclick="pageTracker._trackPageview('/outgoing/www.amazon.co.uk/gp/product/0672328968?ie=UTF8_038_tag=subsofcode-21_038_linkCode=as2_038_camp=1634_038_creative=6738_038_creativeASIN=0672328968&amp;referer=');">Agile Java Development with Spring, Hibernate and Eclipse</a> written by Anil Hemrajani. Hemrajani writes about the POJOs but still uses the Entity Approach throughout the book.</p>
<p>Rich Domain Model ain’t a silver bullet but first few encounters have been very positive and looking forward on applying it more and more in the future projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.substanceofcode.com/2007/01/17/from-anemic-to-rich-domain-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
