<?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: DDD: Repository Implementation Patterns</title>
	<atom:link href="http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Wed, 19 Jun 2013 17:39:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: matt kocaj</title>
		<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/#comment-1854</link>
		<dc:creator>matt kocaj</dc:creator>
		<pubDate>Fri, 11 Feb 2011 05:49:04 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/09/02/ddd-repository-implementation-patterns.aspx#comment-1854</guid>
		<description>@Nick Drew,

Don&#039;t you mean to say &quot;one repository per aggregate&quot; rather than &quot;one repository per-bounded context&quot;? 

Aren&#039;t bounded contexts parent containers to aggregates and it&#039;s possible to have more than one repo in a BC provided that there&#039;s not more than one repo per aggregate?</description>
		<content:encoded><![CDATA[<p>@Nick Drew,</p>
<p>Don&#8217;t you mean to say &#8220;one repository per aggregate&#8221; rather than &#8220;one repository per-bounded context&#8221;? </p>
<p>Aren&#8217;t bounded contexts parent containers to aggregates and it&#8217;s possible to have more than one repo in a BC provided that there&#8217;s not more than one repo per aggregate?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Drew</title>
		<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/#comment-1853</link>
		<dc:creator>Nick Drew</dc:creator>
		<pubDate>Tue, 08 Sep 2009 13:13:58 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/09/02/ddd-repository-implementation-patterns.aspx#comment-1853</guid>
		<description>I think it&#039;s important to recognise that you should tend towards one repository per-bounded context, not one repository per entity.

So, having a ProductRepository make sense, say in a retail domain, where you may also have a SalesTransactionRepository.

CustomerRepository makes sense, say, in an insurance domain, where you may also have a DocumentRepository (including Quotes and Policies).

The tension comes when you need to cross the bounded context.

If the current transaction is a call centre staff member searching for the quotes for a customer, it is entirely possible that I would use a specification pattern:

documentRepository.getQuotes().SelectMany( q.insuredParties).Where( party.partyKey == currentCustomer.customerKey )

However, if the context is finding all insured risks for quote, then I&#039;d expect there to be something available on the repository for such logic:

documentRepository,
documentRepository.InsuredRisksForQuote( QuoteId )

There are some things that are intrinsically part of the business processes of quotes, and should be first class elements of the domain.  There are others that facilitate integration, and allow external specification.  Defining bounded contexts helps decide when you should focus on one or the other</description>
		<content:encoded><![CDATA[<p>I think it&#8217;s important to recognise that you should tend towards one repository per-bounded context, not one repository per entity.</p>
<p>So, having a ProductRepository make sense, say in a retail domain, where you may also have a SalesTransactionRepository.</p>
<p>CustomerRepository makes sense, say, in an insurance domain, where you may also have a DocumentRepository (including Quotes and Policies).</p>
<p>The tension comes when you need to cross the bounded context.</p>
<p>If the current transaction is a call centre staff member searching for the quotes for a customer, it is entirely possible that I would use a specification pattern:</p>
<p>documentRepository.getQuotes().SelectMany( q.insuredParties).Where( party.partyKey == currentCustomer.customerKey )</p>
<p>However, if the context is finding all insured risks for quote, then I&#8217;d expect there to be something available on the repository for such logic:</p>
<p>documentRepository,<br />
documentRepository.InsuredRisksForQuote( QuoteId )</p>
<p>There are some things that are intrinsically part of the business processes of quotes, and should be first class elements of the domain.  There are others that facilitate integration, and allow external specification.  Defining bounded contexts helps decide when you should focus on one or the other</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nikola Malovic</title>
		<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/#comment-1852</link>
		<dc:creator>Nikola Malovic</dc:creator>
		<pubDate>Sat, 05 Sep 2009 06:51:55 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/09/02/ddd-repository-implementation-patterns.aspx#comment-1852</guid>
		<description>I am also in favor of 3rd option due to two main reasons:
1)	Ubiquitous language is very important part of DDD. 
FindDiscontinuedProducts is expressing a clear business case while FindAll(p=&gt;p.productDiscount&gt;0) does not.
2)	Domain logic in examples #1 and #2 could leak out to application\UI layer using the FindAll \ Query methods.In previous example, logic for what discounted product is inside the method, in second example (functions, dictionaries etc.) that logic is kind-a injected outside. 

IMHO, most an examples of an IRepository&lt;T&gt; usage I’ve seen on the net usually look more like generic Data Mapper then repository. 
</description>
		<content:encoded><![CDATA[<p>I am also in favor of 3rd option due to two main reasons:<br />
1)	Ubiquitous language is very important part of DDD.<br />
FindDiscontinuedProducts is expressing a clear business case while FindAll(p=>p.productDiscount>0) does not.<br />
2)	Domain logic in examples #1 and #2 could leak out to application\UI layer using the FindAll \ Query methods.In previous example, logic for what discounted product is inside the method, in second example (functions, dictionaries etc.) that logic is kind-a injected outside. </p>
<p>IMHO, most an examples of an IRepository<t> usage I’ve seen on the net usually look more like generic Data Mapper then repository.<br />
</t></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Blumhardt</title>
		<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/#comment-1851</link>
		<dc:creator>Nicholas Blumhardt</dc:creator>
		<pubDate>Fri, 04 Sep 2009 07:03:38 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/09/02/ddd-repository-implementation-patterns.aspx#comment-1851</guid>
		<description>@Jimmy I meant within your classifications of Repository types :) </description>
		<content:encoded><![CDATA[<p>@Jimmy I meant within your classifications of Repository types <img src='http://lostechies.com/jimmybogard/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eyston</title>
		<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/#comment-1850</link>
		<dc:creator>Eyston</dc:creator>
		<pubDate>Thu, 03 Sep 2009 18:32:11 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/09/02/ddd-repository-implementation-patterns.aspx#comment-1850</guid>
		<description>I guess I&#039;m lazy in that I use ISession as my UoW directly :)  I have SM (IoC) manage that but decide I don&#039;t like having the session plugged into several things per request.  Now I generally try to structure things so that the object that initiates the UoW is the only one that is auto-wired a session and the UoW (session) is passed to any query object that needs it.

I don&#039;t know if this is valid, but I see parallels between Controllerless Actions and Query Objects (vs. a standard Controller and Repositories with custom query methods).</description>
		<content:encoded><![CDATA[<p>I guess I&#8217;m lazy in that I use ISession as my UoW directly <img src='http://lostechies.com/jimmybogard/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I have SM (IoC) manage that but decide I don&#8217;t like having the session plugged into several things per request.  Now I generally try to structure things so that the object that initiates the UoW is the only one that is auto-wired a session and the UoW (session) is passed to any query object that needs it.</p>
<p>I don&#8217;t know if this is valid, but I see parallels between Controllerless Actions and Query Objects (vs. a standard Controller and Repositories with custom query methods).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/#comment-1849</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Thu, 03 Sep 2009 18:13:01 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/09/02/ddd-repository-implementation-patterns.aspx#comment-1849</guid>
		<description>@Eyston

I don&#039;t think it should be.  How often do you really swap out ORMs, or databases?  That&#039;s one of those architecture decisions, hard to reverse and needs to be made very early.</description>
		<content:encoded><![CDATA[<p>@Eyston</p>
<p>I don&#8217;t think it should be.  How often do you really swap out ORMs, or databases?  That&#8217;s one of those architecture decisions, hard to reverse and needs to be made very early.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/#comment-1848</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Thu, 03 Sep 2009 18:11:42 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/09/02/ddd-repository-implementation-patterns.aspx#comment-1848</guid>
		<description>@Nicholas

Nah, that&#039;s still Repository!  We use encapsulated query methods, but those queries could be HQL, ICriteria, or LINQ.</description>
		<content:encoded><![CDATA[<p>@Nicholas</p>
<p>Nah, that&#8217;s still Repository!  We use encapsulated query methods, but those queries could be HQL, ICriteria, or LINQ.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/#comment-1847</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Thu, 03 Sep 2009 18:10:40 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/09/02/ddd-repository-implementation-patterns.aspx#comment-1847</guid>
		<description>@Eyston 

&gt;So do you have the IoC auto wire the session for the Generic Repository Interface?

yeah, and IoC also controls lifetime management.  It&#039;s not the session directly, but something like UoW.</description>
		<content:encoded><![CDATA[<p>@Eyston </p>
<p>>So do you have the IoC auto wire the session for the Generic Repository Interface?</p>
<p>yeah, and IoC also controls lifetime management.  It&#8217;s not the session directly, but something like UoW.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eyston</title>
		<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/#comment-1846</link>
		<dc:creator>Eyston</dc:creator>
		<pubDate>Thu, 03 Sep 2009 14:16:02 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/09/02/ddd-repository-implementation-patterns.aspx#comment-1846</guid>
		<description>Not sure why a DAL has to be ORM agnostic.  It seems like a lot of work / over engineering for little practical benefit.</description>
		<content:encoded><![CDATA[<p>Not sure why a DAL has to be ORM agnostic.  It seems like a lot of work / over engineering for little practical benefit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://lostechies.com/jimmybogard/2009/09/03/ddd-repository-implementation-patterns/#comment-1845</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Thu, 03 Sep 2009 12:57:56 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/09/02/ddd-repository-implementation-patterns.aspx#comment-1845</guid>
		<description>I&#039;ll need to try this again, but last time I played with creating a Generic Repository, I was a little frustrated.  Since ORMs then didn&#039;t support POCOs, and each has its own flavor of attributes/mapping/etc., it ended up that the entity (ie Customer) was tightly coupled to one specific repository implementation (ie LinqToSqlRespository&lt;Customer&gt;).  Creating, say, a EntityFrameworkRepository or NHibernateRepository would mean also changing the entity. </description>
		<content:encoded><![CDATA[<p>I&#8217;ll need to try this again, but last time I played with creating a Generic Repository, I was a little frustrated.  Since ORMs then didn&#8217;t support POCOs, and each has its own flavor of attributes/mapping/etc., it ended up that the entity (ie Customer) was tightly coupled to one specific repository implementation (ie LinqToSqlRespository<customer>).  Creating, say, a EntityFrameworkRepository or NHibernateRepository would mean also changing the entity. </customer></p>
]]></content:encoded>
	</item>
</channel>
</rss>
