<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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>Comments on: Tips for ORM Data Access</title>
	<atom:link href="http://elegantcode.com/2009/11/12/tips-for-orm-data-access/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/</link>
	<description></description>
	<lastBuildDate>Wed, 17 Mar 2010 08:54:42 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: arnshea</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-2/#comment-50396</link>
		<dc:creator>arnshea</dc:creator>
		<pubDate>Mon, 16 Nov 2009 23:00:09 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comment-50396</guid>
		<description>Another approach I&#039;ve tended to favor over the past few years is the following:  

Don&#039;t use ORMs.

Applying the ER model will make you a better OO designer.

Modeling it yourself will encourage you to be sparing; you&#039;ll gravitate towards 3rd normal form where appropriate.

Modeling it yourself will reinforce your understanding of the underlying problem domain which will result in a leaner OO model.

Visual DB design tools = good (no point futzing around with DDL all day).

Object to Relational mappers = bad.  They leak and they&#039;re brittle.  They&#039;re an overapplication of the OO metaphor.

SQL is good.  SQL is easy.  Specifying the what is easier than specifying the how.</description>
		<content:encoded><![CDATA[<p>Another approach I&#8217;ve tended to favor over the past few years is the following:  </p>
<p>Don&#8217;t use ORMs.</p>
<p>Applying the ER model will make you a better OO designer.</p>
<p>Modeling it yourself will encourage you to be sparing; you&#8217;ll gravitate towards 3rd normal form where appropriate.</p>
<p>Modeling it yourself will reinforce your understanding of the underlying problem domain which will result in a leaner OO model.</p>
<p>Visual DB design tools = good (no point futzing around with DDL all day).</p>
<p>Object to Relational mappers = bad.  They leak and they&#8217;re brittle.  They&#8217;re an overapplication of the OO metaphor.</p>
<p>SQL is good.  SQL is easy.  Specifying the what is easier than specifying the how.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Py</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-2/#comment-50328</link>
		<dc:creator>Steve Py</dc:creator>
		<pubDate>Sun, 15 Nov 2009 03:07:08 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comment-50328</guid>
		<description>I don&#039;t agree with avoiding lazy-loading. You can have your cake and eat it too by exposing explicit graph loads via things like Fetch.

The problem with DTOs and the like is type transference where once you flatten an object you need to manage when that flattened entity needs to be re-retrieved as a &quot;real&quot; entity.

For example I may pull a list of lazy-loaded objects, then when I go to the details page I may very well decide to fetch all &quot;child&quot; objects that make up the composition at once if I know I&#039;m probably going to be hitting most of the data anyways. I don&#039;t really want to be dealing with different objects that represent different views of the same data.

As for situations where foo.name = a.b.c.d{.name} I don&#039;t think there&#039;s anything wrong with exposing commonly used &quot;optimizations&quot;. I.e. foo.name = a.dname, where dname = a.b.c.d.name. Nothing more than a simple assertion test is required to assert that a.dname doesn&#039;t start to mean something different to a.b.c.d.name.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t agree with avoiding lazy-loading. You can have your cake and eat it too by exposing explicit graph loads via things like Fetch.</p>
<p>The problem with DTOs and the like is type transference where once you flatten an object you need to manage when that flattened entity needs to be re-retrieved as a &#8220;real&#8221; entity.</p>
<p>For example I may pull a list of lazy-loaded objects, then when I go to the details page I may very well decide to fetch all &#8220;child&#8221; objects that make up the composition at once if I know I&#8217;m probably going to be hitting most of the data anyways. I don&#8217;t really want to be dealing with different objects that represent different views of the same data.</p>
<p>As for situations where foo.name = a.b.c.d{.name} I don&#8217;t think there&#8217;s anything wrong with exposing commonly used &#8220;optimizations&#8221;. I.e. foo.name = a.dname, where dname = a.b.c.d.name. Nothing more than a simple assertion test is required to assert that a.dname doesn&#8217;t start to mean something different to a.b.c.d.name.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-1/#comment-50314</link>
		<dc:creator>Dimitris</dc:creator>
		<pubDate>Sat, 14 Nov 2009 13:18:02 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comment-50314</guid>
		<description>Excuse me for I am a java guy jumping into a .net discussion.
DTOs are an anti-pattern and should be discouraged. Use proper models for the straight cases and/or projections for the advanced cases.

http://anirudhvyas.com/root/2008/04/19/abuses-of-dto-pattern-in-java-world/</description>
		<content:encoded><![CDATA[<p>Excuse me for I am a java guy jumping into a .net discussion.<br />
DTOs are an anti-pattern and should be discouraged. Use proper models for the straight cases and/or projections for the advanced cases.</p>
<p><a href="http://anirudhvyas.com/root/2008/04/19/abuses-of-dto-pattern-in-java-world/" rel="nofollow">http://anirudhvyas.com/root/2008/04/19/abuses-of-dto-pattern-in-java-world/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-1/#comment-50305</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Sat, 14 Nov 2009 02:47:05 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comment-50305</guid>
		<description>&lt;a href=&quot;#comment-50297&quot; rel=&quot;nofollow&quot;&gt;@Scott Parker&lt;/a&gt; 
You don&#039;t need DTOs. They were for EJB1/2.  It was for limiting network hits.  You need something like a ViewModel or projection as he said. Or whatever you want to call it (a Report object?).  Anyway, what it is is a READONLY object that contains attributes of one or more Domain/Entity objects.  For [N]Hibernate you would do something like &quot;select new PersonViewModel(p.firstName, p.lastName, a.city, ph.phoneNumber) from Person as p, Address as a, Phone as ph
where a.person = p
and a.primary = true
and ph.person = p
and ph.primary = true</description>
		<content:encoded><![CDATA[<p><a href="#comment-50297" rel="nofollow">@Scott Parker</a><br />
You don&#8217;t need DTOs. They were for EJB1/2.  It was for limiting network hits.  You need something like a ViewModel or projection as he said. Or whatever you want to call it (a Report object?).  Anyway, what it is is a READONLY object that contains attributes of one or more Domain/Entity objects.  For [N]Hibernate you would do something like &#8220;select new PersonViewModel(p.firstName, p.lastName, a.city, ph.phoneNumber) from Person as p, Address as a, Phone as ph<br />
where a.person = p<br />
and a.primary = true<br />
and ph.person = p<br />
and ph.primary = true</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jarod Ferguson</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-1/#comment-50303</link>
		<dc:creator>Jarod Ferguson</dc:creator>
		<pubDate>Sat, 14 Nov 2009 00:18:49 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comment-50303</guid>
		<description>@scott I responded with a new post here - http://elegantcode.com/2009/11/13/dtos-ddd-the-anemic-domain-model/</description>
		<content:encoded><![CDATA[<p>@scott I responded with a new post here &#8211; <a href="http://elegantcode.com/2009/11/13/dtos-ddd-the-anemic-domain-model/" rel="nofollow">http://elegantcode.com/2009/11/13/dtos-ddd-the-anemic-domain-model/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elegant Code &#187; DTO&#8217;s, DDD &#38; The Anemic Domain Model</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-1/#comment-50302</link>
		<dc:creator>Elegant Code &#187; DTO&#8217;s, DDD &#38; The Anemic Domain Model</dc:creator>
		<pubDate>Sat, 14 Nov 2009 00:17:49 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comment-50302</guid>
		<description>[...] had a comment on my last post Tips for ORM Data Access which i would like like to address with this blog post. I have been trying to wrap my head around [...]</description>
		<content:encoded><![CDATA[<p>[...] had a comment on my last post Tips for ORM Data Access which i would like like to address with this blog post. I have been trying to wrap my head around [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Grundy</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-1/#comment-50298</link>
		<dc:creator>Jason Grundy</dc:creator>
		<pubDate>Fri, 13 Nov 2009 22:29:32 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comment-50298</guid>
		<description>Great post Jarod. Obviously this is something that we&#039;ve talked about a great deal in the past...and in the future I&#039;m sure :)

A few observations specifically on NHibernate:
1) For tracing of SQL statements NHibernate has excellent log4net integration.
2) Projections can often be used instead of Stored Procedures and will often generate very efficient SQL.</description>
		<content:encoded><![CDATA[<p>Great post Jarod. Obviously this is something that we&#8217;ve talked about a great deal in the past&#8230;and in the future I&#8217;m sure <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>A few observations specifically on NHibernate:<br />
1) For tracing of SQL statements NHibernate has excellent log4net integration.<br />
2) Projections can often be used instead of Stored Procedures and will often generate very efficient SQL.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Parker</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-1/#comment-50297</link>
		<dc:creator>Scott Parker</dc:creator>
		<pubDate>Fri, 13 Nov 2009 21:47:49 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comment-50297</guid>
		<description>Wow! This article found me at just the right time. Funny how that works.

I have been trying to wrap my head around the role of the DTO in DDD. My reading of Fowler and Evans seems to indicate that you ought to have your domain objects themselves mapping into your database, rather than dedicated function-less DTOs. Relying on DTOs that are then handled by Services seems to lead to what Fowler calls The Anemic Domain Anti-Pattern: http://martinfowler.com/bliki/AnemicDomainModel.html

However, I have a tough time writing Entity classes that operate in that manner that don&#039;t end up rather painful to change and extend.

Since you recommend the practice of using DTOs, do you have any thoughts on the subject?

Thanks!</description>
		<content:encoded><![CDATA[<p>Wow! This article found me at just the right time. Funny how that works.</p>
<p>I have been trying to wrap my head around the role of the DTO in DDD. My reading of Fowler and Evans seems to indicate that you ought to have your domain objects themselves mapping into your database, rather than dedicated function-less DTOs. Relying on DTOs that are then handled by Services seems to lead to what Fowler calls The Anemic Domain Anti-Pattern: <a href="http://martinfowler.com/bliki/AnemicDomainModel.html" rel="nofollow">http://martinfowler.com/bliki/AnemicDomainModel.html</a></p>
<p>However, I have a tough time writing Entity classes that operate in that manner that don&#8217;t end up rather painful to change and extend.</p>
<p>Since you recommend the practice of using DTOs, do you have any thoughts on the subject?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jarod Ferguson</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-1/#comment-50295</link>
		<dc:creator>Jarod Ferguson</dc:creator>
		<pubDate>Fri, 13 Nov 2009 20:29:29 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comment-50295</guid>
		<description>@ng
CQS is great, though not always applicable in the context in which I have heard Greg and Udi speak about it, which is usually large scale distributed messaging. 

I think the common concept here, which is not new to cqs, is that I may have one model that I use for complex domain logic, saving &amp; updating, and another simplified one for reading. (or even seperate tiers)

“Aggregates cannot call into other aggregates children”
Yes, only for updates/inserts. If your doing CQS they would not be the same anyway right :)</description>
		<content:encoded><![CDATA[<p>@ng<br />
CQS is great, though not always applicable in the context in which I have heard Greg and Udi speak about it, which is usually large scale distributed messaging. </p>
<p>I think the common concept here, which is not new to cqs, is that I may have one model that I use for complex domain logic, saving &#038; updating, and another simplified one for reading. (or even seperate tiers)</p>
<p>“Aggregates cannot call into other aggregates children”<br />
Yes, only for updates/inserts. If your doing CQS they would not be the same anyway right <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-1/#comment-50283</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Fri, 13 Nov 2009 10:28:59 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comment-50283</guid>
		<description>You should fix your apostrophe&#039;s, it will make the article sound more authorittative.</description>
		<content:encoded><![CDATA[<p>You should fix your apostrophe&#8217;s, it will make the article sound more authorittative.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
