<?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: Designing the Repository interface</title>
	<atom:link href="http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/</link>
	<description>A weblog about software engineering, Architecture, Technology an other things we like.</description>
	<lastBuildDate>Thu, 11 Mar 2010 12:35:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Allard</title>
		<link>http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/comment-page-1/#comment-30166</link>
		<dc:creator>Allard</dc:creator>
		<pubDate>Wed, 03 Mar 2010 14:31:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/#comment-30166</guid>
		<description>If you use the &quot;Separated Interface Pattern&quot;, you don&#039;t have a dependency from Domain to Infrastructure, but the other way around. As you state, your service layer cannot choose which implementation to use. That&#039;s where you use IoC for. When you build up your web-app, you choose which jars are included in the war file. One of these jars will contain an IoC configuration file (e.g. spring context) which is loaded and creates the repository implementation.

All the service layer needs to know is: &quot;at runtime, some form of repository is provided to me&quot;. Alternatively, you can use an Abstract Factory to retrieve a repository instance. Personally, I prefer IoC.

Hope this answers your question.</description>
		<content:encoded><![CDATA[<p>If you use the &#8220;Separated Interface Pattern&#8221;, you don&#8217;t have a dependency from Domain to Infrastructure, but the other way around. As you state, your service layer cannot choose which implementation to use. That&#8217;s where you use IoC for. When you build up your web-app, you choose which jars are included in the war file. One of these jars will contain an IoC configuration file (e.g. spring context) which is loaded and creates the repository implementation.</p>
<p>All the service layer needs to know is: &#8220;at runtime, some form of repository is provided to me&#8221;. Alternatively, you can use an Abstract Factory to retrieve a repository instance. Personally, I prefer IoC.</p>
<p>Hope this answers your question.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Melle Koning</title>
		<link>http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/comment-page-1/#comment-30165</link>
		<dc:creator>Melle Koning</dc:creator>
		<pubDate>Wed, 03 Mar 2010 13:51:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/#comment-30165</guid>
		<description>Hello Allard, great article. In our developmentgroup we are currently busy with a refactoring project &quot;Design For Testability&quot; and moving the Repository-interface out of the persistance layer and into the Domain Layer is exactly the way we go as well. Because we need to create stubbed/mocked implementations of the Repository, that do not have any dependency to our ORM-persistance store this is very defendable. What I miss though in the clear pictures is; where do you tigh everything together? That is, if you do not have a dependency from your application-layer to your persistance layer anymore than where do you buildup the implementation of the Repository that is created for persistance? Am I missing the Infrastructure layer which contains a Factory or IoC to loadup the actual repositories/services?</description>
		<content:encoded><![CDATA[<p>Hello Allard, great article. In our developmentgroup we are currently busy with a refactoring project &#8220;Design For Testability&#8221; and moving the Repository-interface out of the persistance layer and into the Domain Layer is exactly the way we go as well. Because we need to create stubbed/mocked implementations of the Repository, that do not have any dependency to our ORM-persistance store this is very defendable. What I miss though in the clear pictures is; where do you tigh everything together? That is, if you do not have a dependency from your application-layer to your persistance layer anymore than where do you buildup the implementation of the Repository that is created for persistance? Am I missing the Infrastructure layer which contains a Factory or IoC to loadup the actual repositories/services?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allard</title>
		<link>http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/comment-page-1/#comment-24622</link>
		<dc:creator>Allard</dc:creator>
		<pubDate>Wed, 08 Jul 2009 11:45:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/#comment-24622</guid>
		<description>Hi Aleksandar,

thanks for your comment.

placing the interfaces in a separate JAR gives you almost all of the benefits I described in my post. However, that will likely create a jar file creating only very few classes that are, in my opinion, conceptually tightly coupled to the domain. That&#039;s why personally, I would prefer to place it in the jar where the domain is implemented.</description>
		<content:encoded><![CDATA[<p>Hi Aleksandar,</p>
<p>thanks for your comment.</p>
<p>placing the interfaces in a separate JAR gives you almost all of the benefits I described in my post. However, that will likely create a jar file creating only very few classes that are, in my opinion, conceptually tightly coupled to the domain. That&#8217;s why personally, I would prefer to place it in the jar where the domain is implemented.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aleksandar Stoisavljevic</title>
		<link>http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/comment-page-1/#comment-24621</link>
		<dc:creator>Aleksandar Stoisavljevic</dc:creator>
		<pubDate>Wed, 08 Jul 2009 10:10:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/#comment-24621</guid>
		<description>Another good post as we used to from You.

Regarding Your comment: 
&lt;cite&gt;
However, replacing the persistence layer with another one isn’t as easy as it seems when it contains the interface. To be able to do so, you must copy the interface into the new persistence layer implementation. And as any good developers knows, when you’re copying stuff, take your hands off the keyboard, and think for a second. You’re probably doing something wrong.
&lt;/cite&gt;

After few projects on my own in Java and using Maven, I&#039;ve decided to separate Interface of Repository and it&#039;s implementation. So I actually have two different JAR&#039;s that is specified as dependency in Application Layer. As You can see there is no need to copy interface in domain layer, interface of repository can be left as it is , and when You need another implementation of repository You just write new Interfaces implementation.

I can be more descriptive about this if You wish.</description>
		<content:encoded><![CDATA[<p>Another good post as we used to from You.</p>
<p>Regarding Your comment:<br />
<cite><br />
However, replacing the persistence layer with another one isn’t as easy as it seems when it contains the interface. To be able to do so, you must copy the interface into the new persistence layer implementation. And as any good developers knows, when you’re copying stuff, take your hands off the keyboard, and think for a second. You’re probably doing something wrong.<br />
</cite></p>
<p>After few projects on my own in Java and using Maven, I&#8217;ve decided to separate Interface of Repository and it&#8217;s implementation. So I actually have two different JAR&#8217;s that is specified as dependency in Application Layer. As You can see there is no need to copy interface in domain layer, interface of repository can be left as it is , and when You need another implementation of repository You just write new Interfaces implementation.</p>
<p>I can be more descriptive about this if You wish.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/comment-page-1/#comment-24575</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Sun, 05 Jul 2009 09:20:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/#comment-24575</guid>
		<description>Erik,

It makes sense, when you think about it. Perhaps the reason that most developers do it differently is that the difference between &quot;Domain&quot; and &quot;Core domain&quot; (to use Eric Evans&#039; terminology) is hard to spot at first.

Nice one as usual, Allard.</description>
		<content:encoded><![CDATA[<p>Erik,</p>
<p>It makes sense, when you think about it. Perhaps the reason that most developers do it differently is that the difference between &#8220;Domain&#8221; and &#8220;Core domain&#8221; (to use Eric Evans&#8217; terminology) is hard to spot at first.</p>
<p>Nice one as usual, Allard.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik van Oosten</title>
		<link>http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/comment-page-1/#comment-24567</link>
		<dc:creator>Erik van Oosten</dc:creator>
		<pubDate>Sat, 04 Jul 2009 19:11:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/#comment-24567</guid>
		<description>I had to cheer when I read that yet another colleague believes interfaces are part of the domain packages!</description>
		<content:encoded><![CDATA[<p>I had to cheer when I read that yet another colleague believes interfaces are part of the domain packages!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allard</title>
		<link>http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/comment-page-1/#comment-24513</link>
		<dc:creator>Allard</dc:creator>
		<pubDate>Thu, 02 Jul 2009 07:25:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/#comment-24513</guid>
		<description>Hi Taras,

that&#039;s a very good and valid point you make there. I would lie if switching persistence implementation was a fully transparent and non-intrusive job. Fortunately, I would say, as simple transitions would make our job boring. ;-)

However, all persistence frameworks (ORM or other) provide the same simple set of features: store, fetch and find. How these features are used using a specific ORM tool should be hidden inside the implementation of the persistence layer. Details such as open-session-in-view (which I dislike, but that&#039;s another discussion), caching and transactionality are usually quite nicely abstracted away by frameworks like Spring. But, I have to admit, they aleays leak through at least a little bit.

Recently, I had to replace a JCR (Java Content Repository) with an ORM solution. Unfortunately, the persistence layer was not as nicely decoupled as it could have been (with relatively little investment at the time). The investment seemed big and useless at the time, but would have been well worth the trouble.

Full decoupling is quite hard to achieve and would often require advanced use of things like AOP. Personally, I prefer the pragmatic solutions. If there is a quick win (like keeping the repository interface technology agnostic), I take it. If there are any leaks, make them visible and easy to replace.

Finally, about &quot;query by specification&quot;, there is a very nice topic about that in Evan&#039;s book. If you use the Abstract Factory pattern to create specification objects, it&#039;s easy to create a basic interface that allows you to specify most commons forms of specification (equals, and, or, etc...), regardless of the actual implementation chosen.

I hope this helps.</description>
		<content:encoded><![CDATA[<p>Hi Taras,</p>
<p>that&#8217;s a very good and valid point you make there. I would lie if switching persistence implementation was a fully transparent and non-intrusive job. Fortunately, I would say, as simple transitions would make our job boring. <img src='http://www.gridshore.nl/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>However, all persistence frameworks (ORM or other) provide the same simple set of features: store, fetch and find. How these features are used using a specific ORM tool should be hidden inside the implementation of the persistence layer. Details such as open-session-in-view (which I dislike, but that&#8217;s another discussion), caching and transactionality are usually quite nicely abstracted away by frameworks like Spring. But, I have to admit, they aleays leak through at least a little bit.</p>
<p>Recently, I had to replace a JCR (Java Content Repository) with an ORM solution. Unfortunately, the persistence layer was not as nicely decoupled as it could have been (with relatively little investment at the time). The investment seemed big and useless at the time, but would have been well worth the trouble.</p>
<p>Full decoupling is quite hard to achieve and would often require advanced use of things like AOP. Personally, I prefer the pragmatic solutions. If there is a quick win (like keeping the repository interface technology agnostic), I take it. If there are any leaks, make them visible and easy to replace.</p>
<p>Finally, about &#8220;query by specification&#8221;, there is a very nice topic about that in Evan&#8217;s book. If you use the Abstract Factory pattern to create specification objects, it&#8217;s easy to create a basic interface that allows you to specify most commons forms of specification (equals, and, or, etc&#8230;), regardless of the actual implementation chosen.</p>
<p>I hope this helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taras Tielkes</title>
		<link>http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/comment-page-1/#comment-24502</link>
		<dc:creator>Taras Tielkes</dc:creator>
		<pubDate>Wed, 01 Jul 2009 21:20:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.gridshore.nl/2009/07/01/designing-the-repository-interface/#comment-24502</guid>
		<description>In my experience different persistence technologies come with a totally different set of paradigms. Most ORMs provide a form of &quot;demand-based paging&quot; - swapping relevant parts of the database into memory as lazy (on non-lazy) relationships are traversed. JDBC (through wrappers like spring, or not) and IBatis take a totally different approach. In addition, even the different ORM flavors exhibit substantial differences in a non-trivial model. Usually a mix of lazy and eager fetching (for the same relationship, depending on circumstances), approaches like open-session-in-view, differences in transactional semantics, caching, etc, make swapping a persistence layer transparently a pipe dream.

Specific to DDD, implementing patterns like query-by-specification are wildly different (sometime non-portable) across persistence technologies.

Any details on how you managed to pull this off?</description>
		<content:encoded><![CDATA[<p>In my experience different persistence technologies come with a totally different set of paradigms. Most ORMs provide a form of &#8220;demand-based paging&#8221; &#8211; swapping relevant parts of the database into memory as lazy (on non-lazy) relationships are traversed. JDBC (through wrappers like spring, or not) and IBatis take a totally different approach. In addition, even the different ORM flavors exhibit substantial differences in a non-trivial model. Usually a mix of lazy and eager fetching (for the same relationship, depending on circumstances), approaches like open-session-in-view, differences in transactional semantics, caching, etc, make swapping a persistence layer transparently a pipe dream.</p>
<p>Specific to DDD, implementing patterns like query-by-specification are wildly different (sometime non-portable) across persistence technologies.</p>
<p>Any details on how you managed to pull this off?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
