<?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: Domain Driven Design applied</title>
	<atom:link href="http://blog.jteam.nl/2009/07/28/domain-driven-design-applied/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jteam.nl/2009/07/28/domain-driven-design-applied/</link>
	<description>Keep updated on what we&#039;re doing!</description>
	<lastBuildDate>Sat, 04 Sep 2010 13:07:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: DDD and modern software development &#171; JTeam Blog / JTeam: Enterprise Java, Open Source, software solutions, Amsterdam</title>
		<link>http://blog.jteam.nl/2009/07/28/domain-driven-design-applied/comment-page-1/#comment-669</link>
		<dc:creator>DDD and modern software development &#171; JTeam Blog / JTeam: Enterprise Java, Open Source, software solutions, Amsterdam</dc:creator>
		<pubDate>Tue, 08 Sep 2009 15:01:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jteam.nl/?p=598#comment-669</guid>
		<description>[...] For those people reading this blog item and think: &#8220;What is DDD?&#8220;. DDD is an abbreviation for Domain Driven Design. We have been writing about DDD before on this blog: &#8220;The misunderstanding of domain driven design&#8220;, &#8220;Domain Driven Design applied&#8220;. [...]</description>
		<content:encoded><![CDATA[<p>[...] For those people reading this blog item and think: &#8220;What is DDD?&#8220;. DDD is an abbreviation for Domain Driven Design. We have been writing about DDD before on this blog: &#8220;The misunderstanding of domain driven design&#8220;, &#8220;Domain Driven Design applied&#8220;. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allard Buijze</title>
		<link>http://blog.jteam.nl/2009/07/28/domain-driven-design-applied/comment-page-1/#comment-493</link>
		<dc:creator>Allard Buijze</dc:creator>
		<pubDate>Thu, 06 Aug 2009 08:35:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jteam.nl/?p=598#comment-493</guid>
		<description>Hi Oliver,

first let me make one thing clear. I don&#039;t think there is anything wrong with the approach to having the &quot;domain operations&quot; called by the UI layer. It&#039;s just that in our application we chose to use the Use Cases as operations in the service layer. That does not mean that there is one service method per domain method. This approach leads to very thin client layers that typically only need to do a single call, as a user interface usually deals with one use case at a time. This also makes transaction management very easy. Just annotate the service methods with Spring&#039;s @Transactional, and you&#039;re done. Persistence is managed for you.

As I understand, you prefer to have the UI Controller in charge, and I will not be the one to say that is the wrong way to go. I am sure that, in some circumstances (e.g. when the amount of use cases is simply too high), your approach leads to easier to maintain code than mine. But in our case, and you&#039;ll just have to trust me on that, since I am not allowed to publish the codebase, it just wasn&#039;t the most suitable approach.

And to answer you &quot;service/repository side-by-side question&quot;: no, only the service layer accesses the repositories. The service layer is responsible for checking security rules, retrieving entities, calling the right methods on them, and then persisting their state again. Of course, most of these rules are delegated to more specific implementations (e.g. security strategy).

Anyway, if you have written anything about the approach you use in you applications, I am eager to read about it.

Regards,

Allard</description>
		<content:encoded><![CDATA[<p>Hi Oliver,</p>
<p>first let me make one thing clear. I don&#8217;t think there is anything wrong with the approach to having the &#8220;domain operations&#8221; called by the UI layer. It&#8217;s just that in our application we chose to use the Use Cases as operations in the service layer. That does not mean that there is one service method per domain method. This approach leads to very thin client layers that typically only need to do a single call, as a user interface usually deals with one use case at a time. This also makes transaction management very easy. Just annotate the service methods with Spring&#8217;s @Transactional, and you&#8217;re done. Persistence is managed for you.</p>
<p>As I understand, you prefer to have the UI Controller in charge, and I will not be the one to say that is the wrong way to go. I am sure that, in some circumstances (e.g. when the amount of use cases is simply too high), your approach leads to easier to maintain code than mine. But in our case, and you&#8217;ll just have to trust me on that, since I am not allowed to publish the codebase, it just wasn&#8217;t the most suitable approach.</p>
<p>And to answer you &#8220;service/repository side-by-side question&#8221;: no, only the service layer accesses the repositories. The service layer is responsible for checking security rules, retrieving entities, calling the right methods on them, and then persisting their state again. Of course, most of these rules are delegated to more specific implementations (e.g. security strategy).</p>
<p>Anyway, if you have written anything about the approach you use in you applications, I am eager to read about it.</p>
<p>Regards,</p>
<p>Allard</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oliver Gierke</title>
		<link>http://blog.jteam.nl/2009/07/28/domain-driven-design-applied/comment-page-1/#comment-475</link>
		<dc:creator>Oliver Gierke</dc:creator>
		<pubDate>Tue, 04 Aug 2009 16:40:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jteam.nl/?p=598#comment-475</guid>
		<description>Hey Allard,

thanks for your response. I&#039;ll try to get it down one by one.

The save method. This actually is a combination of what you might express as create(Entity entity) and update(Entity entity) method combination. I think we can agree on the client having a necessity to create and update entitys it might have edited via the service interface, can&#039;t we? I tend to merge this into one method to make the distincion not to bother the client. Although in very simple cases a call to save might result in a simple delegate to a repository, but in most cases there are additional steps do be done.

Your linkAccount method makes sense as you treat the IDs of entities as value objects. In general we hardly ever need more than a Long so that the additional abstraction does not add much value. I agree that this way the service interface has a more &quot;domainic&quot; surface but the benefit seems rather small to me. In contrast, stripped down to the Long variant, the interface becomes much more technical that if you&#039;d handed out the entity and let the client to the work on the entity itself through domain functionality e.g. account.link(user). To me the service interface you suggest leads to a very procedural way of programming at the client side whereas mine results in a rather thin layer (and thus is much more like a facade) above the multiple repositories. This seconds your thoughts on building modular interfaces.

Regarding your last paragraph: How do you deal with services and repositories in combination then? Do you use them side-by-side from a clients point of view (suppose the mentioned (create, update, getAllFoo) functionality clients will need to access?

Very cool to discuss this stuff here. I really like shading light from different angles on this topic :).

Regards,
Ollie</description>
		<content:encoded><![CDATA[<p>Hey Allard,</p>
<p>thanks for your response. I&#8217;ll try to get it down one by one.</p>
<p>The save method. This actually is a combination of what you might express as create(Entity entity) and update(Entity entity) method combination. I think we can agree on the client having a necessity to create and update entitys it might have edited via the service interface, can&#8217;t we? I tend to merge this into one method to make the distincion not to bother the client. Although in very simple cases a call to save might result in a simple delegate to a repository, but in most cases there are additional steps do be done.</p>
<p>Your linkAccount method makes sense as you treat the IDs of entities as value objects. In general we hardly ever need more than a Long so that the additional abstraction does not add much value. I agree that this way the service interface has a more &#8220;domainic&#8221; surface but the benefit seems rather small to me. In contrast, stripped down to the Long variant, the interface becomes much more technical that if you&#8217;d handed out the entity and let the client to the work on the entity itself through domain functionality e.g. account.link(user). To me the service interface you suggest leads to a very procedural way of programming at the client side whereas mine results in a rather thin layer (and thus is much more like a facade) above the multiple repositories. This seconds your thoughts on building modular interfaces.</p>
<p>Regarding your last paragraph: How do you deal with services and repositories in combination then? Do you use them side-by-side from a clients point of view (suppose the mentioned (create, update, getAllFoo) functionality clients will need to access?</p>
<p>Very cool to discuss this stuff here. I really like shading light from different angles on this topic <img src='http://blog.jteam.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Regards,<br />
Ollie</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allard Buijze</title>
		<link>http://blog.jteam.nl/2009/07/28/domain-driven-design-applied/comment-page-1/#comment-469</link>
		<dc:creator>Allard Buijze</dc:creator>
		<pubDate>Mon, 03 Aug 2009 19:09:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jteam.nl/?p=598#comment-469</guid>
		<description>Oliver,

thanks for your reply. I&#039;m not sure I really understand what you mean in your first point. To me, having a &quot;save&quot; method on your service layer is rather technical. Instead, I like to see my application (aka service) layers as the functional boundary of an application. Everything your application is supposed to do, is done within those boundaries. That means that any entities that cross that boundary are detached from any transaction or persistence context and are considered &quot;lost&quot;. You could see the application services as use case controllers.

Your example of linking an account to a user, would have a method like the following on your service layer: public void linkAccount(AccountId accountId, UserId userId), quite similar to what you said.

Inside, you would retrieve the corresponding entities from the repository and use the link method on them.

It doesn&#039;t per-se make it more accessible to a client, but it is the cleanest way to force some form of separation between the application and ui layers. I am not saying this *the* way to do it. It is just a way we did it, and for our application, with relatively few use cases, these simple rules have helped our (relatively small, but flexible) team keep a sound and nicely decoupled codebase in the months that we have been developing this application. We didn&#039;t have any discussions as of where to put certain logic. Everything is clear and well confined within a predefined boundary.

Of course, this approach has some drawbacks if your application has hundreds of different use cases. But still, with a nice modular approach, you should still be able to keep a relatively good overview, even in this case.

About your second option. Persisting domain objects is not the responsibility of the service layer. Repositories are responsible for that.

Hope that clarifies my point of view.</description>
		<content:encoded><![CDATA[<p>Oliver,</p>
<p>thanks for your reply. I&#8217;m not sure I really understand what you mean in your first point. To me, having a &#8220;save&#8221; method on your service layer is rather technical. Instead, I like to see my application (aka service) layers as the functional boundary of an application. Everything your application is supposed to do, is done within those boundaries. That means that any entities that cross that boundary are detached from any transaction or persistence context and are considered &#8220;lost&#8221;. You could see the application services as use case controllers.</p>
<p>Your example of linking an account to a user, would have a method like the following on your service layer: public void linkAccount(AccountId accountId, UserId userId), quite similar to what you said.</p>
<p>Inside, you would retrieve the corresponding entities from the repository and use the link method on them.</p>
<p>It doesn&#8217;t per-se make it more accessible to a client, but it is the cleanest way to force some form of separation between the application and ui layers. I am not saying this *the* way to do it. It is just a way we did it, and for our application, with relatively few use cases, these simple rules have helped our (relatively small, but flexible) team keep a sound and nicely decoupled codebase in the months that we have been developing this application. We didn&#8217;t have any discussions as of where to put certain logic. Everything is clear and well confined within a predefined boundary.</p>
<p>Of course, this approach has some drawbacks if your application has hundreds of different use cases. But still, with a nice modular approach, you should still be able to keep a relatively good overview, even in this case.</p>
<p>About your second option. Persisting domain objects is not the responsibility of the service layer. Repositories are responsible for that.</p>
<p>Hope that clarifies my point of view.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allard Buijze</title>
		<link>http://blog.jteam.nl/2009/07/28/domain-driven-design-applied/comment-page-1/#comment-466</link>
		<dc:creator>Allard Buijze</dc:creator>
		<pubDate>Mon, 03 Aug 2009 15:05:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jteam.nl/?p=598#comment-466</guid>
		<description>Christoph, 

thanks for your comment. You might like my other blog entries about DDD in that case too: http://www.gridshore.nl/category/ddd/

Regards,

Allard</description>
		<content:encoded><![CDATA[<p>Christoph, </p>
<p>thanks for your comment. You might like my other blog entries about DDD in that case too: <a href="http://www.gridshore.nl/category/ddd/" rel="nofollow">http://www.gridshore.nl/category/ddd/</a></p>
<p>Regards,</p>
<p>Allard</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christoph Rueger</title>
		<link>http://blog.jteam.nl/2009/07/28/domain-driven-design-applied/comment-page-1/#comment-438</link>
		<dc:creator>Christoph Rueger</dc:creator>
		<pubDate>Thu, 30 Jul 2009 09:27:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jteam.nl/?p=598#comment-438</guid>
		<description>Hi Allard,
this is very interesting post dealing with questions I ask myself over and over again. 
Especially your section about persistence, what to put in the DataAccessLayer and what to put in the Service layer. 

Looking forward to more articles like that.

Christoph</description>
		<content:encoded><![CDATA[<p>Hi Allard,<br />
this is very interesting post dealing with questions I ask myself over and over again.<br />
Especially your section about persistence, what to put in the DataAccessLayer and what to put in the Service layer. </p>
<p>Looking forward to more articles like that.</p>
<p>Christoph</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oliver Gierke</title>
		<link>http://blog.jteam.nl/2009/07/28/domain-driven-design-applied/comment-page-1/#comment-433</link>
		<dc:creator>Oliver Gierke</dc:creator>
		<pubDate>Wed, 29 Jul 2009 16:52:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jteam.nl/?p=598#comment-433</guid>
		<description>Cool sample! One thing I&#039;d like to ask is why you insist on not accepting any entities at the service layer. I tend to see the following consequences:

1. Abstraction of the service layer decreases. You get a rather technical un-domain-driven interface of the service layer by doing that.
2. How do you expose persisting the domain object then? It needs transactional boundary, so I tend to expose a save(..) method on the service.

I prefer to let the clients of the service layer use the rich methods of the entities to do more than getters and setters and hand it to the service layer to apply persistence. Let me give an example you can probably follw very easily. You have Accounts and Users that can be linked to each other. How would you expose this functionality to the clients of a service? I&#039;d take the route of offering an Account.link(User user) method, letting that method check certain domain constraints and let this be invoked by the client and hand the account back to the service to persist the operation. If I got you right, you rather offer an link(Long accountId, Long userId) via the service and handle the Account.link(User) call inside the service, right? I don&#039;t see how this makes it more accesible to the clients.

Really look forward to hear your opinions on that!

Regards,
Ollie</description>
		<content:encoded><![CDATA[<p>Cool sample! One thing I&#8217;d like to ask is why you insist on not accepting any entities at the service layer. I tend to see the following consequences:</p>
<p>1. Abstraction of the service layer decreases. You get a rather technical un-domain-driven interface of the service layer by doing that.<br />
2. How do you expose persisting the domain object then? It needs transactional boundary, so I tend to expose a save(..) method on the service.</p>
<p>I prefer to let the clients of the service layer use the rich methods of the entities to do more than getters and setters and hand it to the service layer to apply persistence. Let me give an example you can probably follw very easily. You have Accounts and Users that can be linked to each other. How would you expose this functionality to the clients of a service? I&#8217;d take the route of offering an Account.link(User user) method, letting that method check certain domain constraints and let this be invoked by the client and hand the account back to the service to persist the operation. If I got you right, you rather offer an link(Long accountId, Long userId) via the service and handle the Account.link(User) call inside the service, right? I don&#8217;t see how this makes it more accesible to the clients.</p>
<p>Really look forward to hear your opinions on that!</p>
<p>Regards,<br />
Ollie</p>
]]></content:encoded>
	</item>
</channel>
</rss>
