<?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: How to create fully encapsulated Domain Models</title>
	<atom:link href="http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/</link>
	<description>Enterprise Development Expert &#38; SOA Specialist</description>
	<lastBuildDate>Sun, 14 Mar 2010 06:27:00 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-2/#comment-36433</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Fri, 17 Jul 2009 14:40:19 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-36433</guid>
		<description>Paul,

Don&#039;t worry about the &quot;as before&quot; as the code was taken from an article in which it was developed bit by bit.

The DomainEvents class is infrastructure, below both the Serivce Layer and the Domain Model.

On the name IHandle, might I suggest maybe IHandleDomainEvents&lt;T&gt; instead.

Thanks for your comments.</description>
		<content:encoded><![CDATA[<p>Paul,</p>
<p>Don&#8217;t worry about the &#8220;as before&#8221; as the code was taken from an article in which it was developed bit by bit.</p>
<p>The DomainEvents class is infrastructure, below both the Serivce Layer and the Domain Model.</p>
<p>On the name IHandle, might I suggest maybe IHandleDomainEvents<t> instead.</p>
<p>Thanks for your comments.</t></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Linton</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-2/#comment-36428</link>
		<dc:creator>Paul Linton</dc:creator>
		<pubDate>Thu, 16 Jul 2009 07:04:00 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-36428</guid>
		<description>I really liked your &#039;Make Roles Explicit&#039; talk and found your web site as a result.  The method you describe here to handle Domain events seems like it will fix a particular problem I have in my Domain where an action on a Customer should cause various Accounting action to take place.
Can you clear up for me a couple of questions?
In DomainEvents there is a comment next to the Container declaration &quot;as before&quot;, I can&#039;t find the earlier reference.
I assume IContainer is some DI container (StructureMap?) which raises the question of &quot;Where does the DomainEvents class live&quot;?  If it goes in the Domain then the Domain depends on the DI container, if it goes in a Service layer then the Domain depends on that service layer.  Or is IContainer some abstraction of DI defined in the Domain?
Will I be in a state of sin if I call the Handles interface IHandle (seems to fit the IWashDishes thought process)?</description>
		<content:encoded><![CDATA[<p>I really liked your &#8216;Make Roles Explicit&#8217; talk and found your web site as a result.  The method you describe here to handle Domain events seems like it will fix a particular problem I have in my Domain where an action on a Customer should cause various Accounting action to take place.<br />
Can you clear up for me a couple of questions?<br />
In DomainEvents there is a comment next to the Container declaration &#8220;as before&#8221;, I can&#8217;t find the earlier reference.<br />
I assume IContainer is some DI container (StructureMap?) which raises the question of &#8220;Where does the DomainEvents class live&#8221;?  If it goes in the Domain then the Domain depends on the DI container, if it goes in a Service layer then the Domain depends on that service layer.  Or is IContainer some abstraction of DI defined in the Domain?<br />
Will I be in a state of sin if I call the Handles interface IHandle (seems to fit the IWashDishes thought process)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-2/#comment-36376</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Thu, 09 Jul 2009 13:10:22 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-36376</guid>
		<description>Thomas,

I read through the post and it describes Craig Larman&#039;s view on *Problem Domain Object Models*, not the Domain Model software artifact I&#039;m describing in this post - I&#039;m afraid it&#039;s a bit of an apples to oranges comparison.

I do think that more developers should know about the kind of modeling you describe in your post, though.

Thanks for the link.

-- Udi</description>
		<content:encoded><![CDATA[<p>Thomas,</p>
<p>I read through the post and it describes Craig Larman&#8217;s view on *Problem Domain Object Models*, not the Domain Model software artifact I&#8217;m describing in this post &#8211; I&#8217;m afraid it&#8217;s a bit of an apples to oranges comparison.</p>
<p>I do think that more developers should know about the kind of modeling you describe in your post, though.</p>
<p>Thanks for the link.</p>
<p>&#8211; Udi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-2/#comment-36371</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Tue, 07 Jul 2009 20:58:12 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-36371</guid>
		<description>Check out this summray of Craig Larman&#039;s view on this: 
http://blogbustingbeats.wordpress.com/2009/07/07/405/</description>
		<content:encoded><![CDATA[<p>Check out this summray of Craig Larman&#8217;s view on this:<br />
<a href="http://blogbustingbeats.wordpress.com/2009/07/07/405/" rel="nofollow">http://blogbustingbeats.wordpress.com/2009/07/07/405/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Domain Events - Salvation</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-2/#comment-36218</link>
		<dc:creator>Domain Events - Salvation</dc:creator>
		<pubDate>Sun, 14 Jun 2009 12:34:15 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-36218</guid>
		<description>[...] It started by looking for how to create fully encapsulated domain models. [...]</description>
		<content:encoded><![CDATA[<p>[...] It started by looking for how to create fully encapsulated domain models. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-2/#comment-36013</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Fri, 06 Feb 2009 15:06:05 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-36013</guid>
		<description>Nuno,

Your English is perfectly understandable - no worries :)

I did go through some posts on your blog - looks like good stuff. Welcome to the conversation.</description>
		<content:encoded><![CDATA[<p>Nuno,</p>
<p>Your English is perfectly understandable &#8211; no worries <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I did go through some posts on your blog &#8211; looks like good stuff. Welcome to the conversation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nuno Lopes</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-2/#comment-36008</link>
		<dc:creator>Nuno Lopes</dc:creator>
		<pubDate>Wed, 04 Feb 2009 22:25:32 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-36008</guid>
		<description>I see, now I understand. Thank you very much for your answer Udi.

I reviewed the post in my blog as the English was really bad. If you care to read it (or re-read it) Udi and pass on some comments would be really a learning experience.

It mainly addresses the Domain Model for the example you used but in a different and better way (at least IMHO).

What may interest you is that I may be wrong but my approach to the Domain Model and the way you propose Domain Errors to be reported back to the caller don&#039;t mingle that well. At least I don&#039;t see a recurring technique to apply them. Especially when Domain Objects call each other services to perform their activity.

That is why I don&#039;t like how errors are reported.

Nuno 
PS: Has you may have guessed already, English is not my mother language, so I&#039;ll try to be carefull so that my impressions can get across without much effort.</description>
		<content:encoded><![CDATA[<p>I see, now I understand. Thank you very much for your answer Udi.</p>
<p>I reviewed the post in my blog as the English was really bad. If you care to read it (or re-read it) Udi and pass on some comments would be really a learning experience.</p>
<p>It mainly addresses the Domain Model for the example you used but in a different and better way (at least IMHO).</p>
<p>What may interest you is that I may be wrong but my approach to the Domain Model and the way you propose Domain Errors to be reported back to the caller don&#8217;t mingle that well. At least I don&#8217;t see a recurring technique to apply them. Especially when Domain Objects call each other services to perform their activity.</p>
<p>That is why I don&#8217;t like how errors are reported.</p>
<p>Nuno<br />
PS: Has you may have guessed already, English is not my mother language, so I&#8217;ll try to be carefull so that my impressions can get across without much effort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-2/#comment-36007</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Wed, 04 Feb 2009 16:33:10 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-36007</guid>
		<description>Nuno,

&gt; Consider a Web Application where this service is in assembly that is directely referenced.

It doesn&#039;t work like that. The web app would send a message to a different process which would run the above service layer.

You can find out more about nServiceBus on the site http://www.NServiceBus.com. Take a look at the overview section.</description>
		<content:encoded><![CDATA[<p>Nuno,</p>
<p>> Consider a Web Application where this service is in assembly that is directely referenced.</p>
<p>It doesn&#8217;t work like that. The web app would send a message to a different process which would run the above service layer.</p>
<p>You can find out more about nServiceBus on the site <a href="http://www.NServiceBus.com" rel="nofollow">http://www.NServiceBus.com</a>. Take a look at the overview section.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nuno Lopes</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-2/#comment-36003</link>
		<dc:creator>Nuno Lopes</dc:creator>
		<pubDate>Tue, 03 Feb 2009 18:28:03 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-36003</guid>
		<description>Hello, 

Started commenting the ideas presented regarding modeling the domain, but it started to be too long. So I stopped, put together the ideas contrasting and complementing the one presented here on an article in my Blog.

Just started blogging my mind away last weekend so please fill free to point out some deadlocks of mine, I can only learn and share. 

Here it is: 

http://movablesharp.blogspot.com/</description>
		<content:encoded><![CDATA[<p>Hello, </p>
<p>Started commenting the ideas presented regarding modeling the domain, but it started to be too long. So I stopped, put together the ideas contrasting and complementing the one presented here on an article in my Blog.</p>
<p>Just started blogging my mind away last weekend so please fill free to point out some deadlocks of mine, I can only learn and share. </p>
<p>Here it is: </p>
<p><a href="http://movablesharp.blogspot.com/" rel="nofollow">http://movablesharp.blogspot.com/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nuno Lopes</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-35996</link>
		<dc:creator>Nuno Lopes</dc:creator>
		<pubDate>Mon, 02 Feb 2009 22:45:10 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-35996</guid>
		<description>Wow I&#039;m so late.

I like the nServiceBus idea (it seams that you are using it right?).

Consider a Web Application where this service is in assembly that is directely referenced.

Using that scheme, what would the caller of the AddGameToCartMessageHandler have to do to check for errors?

Do you have any framework that we can read to understand this? I mean
BaseMessageHandler, what is this? What does it do?

If it what I think it is I like in principle, but would like to see it further :)

Nuno</description>
		<content:encoded><![CDATA[<p>Wow I&#8217;m so late.</p>
<p>I like the nServiceBus idea (it seams that you are using it right?).</p>
<p>Consider a Web Application where this service is in assembly that is directely referenced.</p>
<p>Using that scheme, what would the caller of the AddGameToCartMessageHandler have to do to check for errors?</p>
<p>Do you have any framework that we can read to understand this? I mean<br />
BaseMessageHandler, what is this? What does it do?</p>
<p>If it what I think it is I like in principle, but would like to see it further <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Nuno</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-35859</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Wed, 17 Dec 2008 20:16:23 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-35859</guid>
		<description>Pete,

You can expose collections as IEnumerable&lt;T&gt; so that there won&#039;t be any Add/Remove methods available.

On your NHibernate specific question, you wouldn&#039;t do anything different in the mapping to work with these interfaces. Just use Ayende&#039;s repository wrapper around it.</description>
		<content:encoded><![CDATA[<p>Pete,</p>
<p>You can expose collections as IEnumerable<t> so that there won&#8217;t be any Add/Remove methods available.</p>
<p>On your NHibernate specific question, you wouldn&#8217;t do anything different in the mapping to work with these interfaces. Just use Ayende&#8217;s repository wrapper around it.</t></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Grazaitis</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-35855</link>
		<dc:creator>Pete Grazaitis</dc:creator>
		<pubDate>Tue, 16 Dec 2008 21:44:52 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-35855</guid>
		<description>I know that by default the public exposure of Properties for NHibernate ORM allows for easy adoption of the Anemic anti-pattern.

By locking down the set&#039;s to internal,private, or protected you can give NHibernate special set access via the proxy but keep the entities better encapsulated.

However, I have noticed that for collections, like Lists/Bags we may lock down the setter but leave the get public.  The problem here is that I can then add/remove items directly from the collection and avoid any Add/Remove methods that employ business logic.

Do you have a recommended solution to avoiding this possibility?  My guess is that you would make the mapping use field level access and avoid a Property altogether.  

My next issue, is NHibernate specific, so I apologize if this is outside the scope.  If the desired solution is field level access, how would this work if I define my class as an interface within the mapper with concrete classes defined as subclasses?  Would I have to define that particular property on every subclass?</description>
		<content:encoded><![CDATA[<p>I know that by default the public exposure of Properties for NHibernate ORM allows for easy adoption of the Anemic anti-pattern.</p>
<p>By locking down the set&#8217;s to internal,private, or protected you can give NHibernate special set access via the proxy but keep the entities better encapsulated.</p>
<p>However, I have noticed that for collections, like Lists/Bags we may lock down the setter but leave the get public.  The problem here is that I can then add/remove items directly from the collection and avoid any Add/Remove methods that employ business logic.</p>
<p>Do you have a recommended solution to avoiding this possibility?  My guess is that you would make the mapping use field level access and avoid a Property altogether.  </p>
<p>My next issue, is NHibernate specific, so I apologize if this is outside the scope.  If the desired solution is field level access, how would this work if I define my class as an interface within the mapper with concrete classes defined as subclasses?  Would I have to define that particular property on every subclass?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-32426</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Mon, 22 Sep 2008 05:43:09 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-32426</guid>
		<description>Nick,

In CQS, you don&#039;t query against the transactional data - so that wouldn&#039;t really hold here.</description>
		<content:encoded><![CDATA[<p>Nick,</p>
<p>In CQS, you don&#8217;t query against the transactional data &#8211; so that wouldn&#8217;t really hold here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-32425</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Mon, 22 Sep 2008 05:42:19 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-32425</guid>
		<description>Colin,

I&#039;d argue for a saga across aggregates.</description>
		<content:encoded><![CDATA[<p>Colin,</p>
<p>I&#8217;d argue for a saga across aggregates.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-32416</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Mon, 22 Sep 2008 03:04:51 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-32416</guid>
		<description>I&#039;m not sure how it violates ask/dont tell. Isn&#039;t that basically the same as command/query separation? In this case, all Colin is doing is querying.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure how it violates ask/dont tell. Isn&#8217;t that basically the same as command/query separation? In this case, all Colin is doing is querying.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin Jack</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-31822</link>
		<dc:creator>Colin Jack</dc:creator>
		<pubDate>Sun, 14 Sep 2008 16:56:56 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-31822</guid>
		<description>&gt; I’m afraid that that violates the “tell, don’t ask” principle of OO.

Depends, if a behaviour crosses aggregates then I think its fine to ask each aggregate whether they want to proceed before starting. Plus if you don&#039;t ask you can still tell them what to do and they will in turn tell you if they can&#039;t fulfil their part (using an exception).

&gt; Also, by and large you don’t have single methods updating across 
&gt; aggregates. The cases where I’ve seen that happen were where the 
&gt; domain model was too big, trying to capture rules across multiple  
&gt; contexts.

Not sure I agree with that, I&#039;ve quite often seen multiple aggregates involved in a transaction. For example if you use party archetype then the party and its role or a relationship could all be involved. Guess it depends on how your domain model is designed though.</description>
		<content:encoded><![CDATA[<p>&gt; I’m afraid that that violates the “tell, don’t ask” principle of OO.</p>
<p>Depends, if a behaviour crosses aggregates then I think its fine to ask each aggregate whether they want to proceed before starting. Plus if you don&#8217;t ask you can still tell them what to do and they will in turn tell you if they can&#8217;t fulfil their part (using an exception).</p>
<p>&gt; Also, by and large you don’t have single methods updating across<br />
&gt; aggregates. The cases where I’ve seen that happen were where the<br />
&gt; domain model was too big, trying to capture rules across multiple<br />
&gt; contexts.</p>
<p>Not sure I agree with that, I&#8217;ve quite often seen multiple aggregates involved in a transaction. For example if you use party archetype then the party and its role or a relationship could all be involved. Guess it depends on how your domain model is designed though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-31512</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Wed, 10 Sep 2008 20:53:16 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-31512</guid>
		<description>Colin,

&gt; My domain classes allow other layers to ask questions, so you can ask can I do this?

I&#039;m afraid that that violates the &quot;tell, don&#039;t ask&quot; principle of OO.

Also, by and large you don&#039;t have single methods updating across aggregates. The cases where I&#039;ve seen that happen were where the domain model was too big, trying to capture rules across multiple contexts.</description>
		<content:encoded><![CDATA[<p>Colin,</p>
<p>> My domain classes allow other layers to ask questions, so you can ask can I do this?</p>
<p>I&#8217;m afraid that that violates the &#8220;tell, don&#8217;t ask&#8221; principle of OO.</p>
<p>Also, by and large you don&#8217;t have single methods updating across aggregates. The cases where I&#8217;ve seen that happen were where the domain model was too big, trying to capture rules across multiple contexts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-31507</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Wed, 10 Sep 2008 20:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-31507</guid>
		<description>Daniel,

About the CONSTANTS - you&#039;d have to set up some kind of injection for your entities, currently not well supported by the ORM tools.

There&#039;s a deeper issue here around who can change the behavior of the domain, and how, and who tests that the domain behaves correctly under the new config, and if this impacts data already saved in the database.

In short, there&#039;s no silver bullet.</description>
		<content:encoded><![CDATA[<p>Daniel,</p>
<p>About the CONSTANTS &#8211; you&#8217;d have to set up some kind of injection for your entities, currently not well supported by the ORM tools.</p>
<p>There&#8217;s a deeper issue here around who can change the behavior of the domain, and how, and who tests that the domain behaves correctly under the new config, and if this impacts data already saved in the database.</p>
<p>In short, there&#8217;s no silver bullet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-31376</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Tue, 09 Sep 2008 12:24:13 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-31376</guid>
		<description>I know I am many months late, but I just happened to see this today and fits nice with what I am doing right now.
What would happen if the values that you access through CONSTANTS would come from configuration? Would it be hard to test the entity as you would depend implicitly on configuration?
Would it be fine have a dependency on IConfiguration in our entity? Would the repository method Get() the place to inject that dependency using some sort of Service Locator?

thanks in advance</description>
		<content:encoded><![CDATA[<p>I know I am many months late, but I just happened to see this today and fits nice with what I am doing right now.<br />
What would happen if the values that you access through CONSTANTS would come from configuration? Would it be hard to test the entity as you would depend implicitly on configuration?<br />
Would it be fine have a dependency on IConfiguration in our entity? Would the repository method Get() the place to inject that dependency using some sort of Service Locator?</p>
<p>thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin Jack</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-31327</link>
		<dc:creator>Colin Jack</dc:creator>
		<pubDate>Mon, 08 Sep 2008 21:41:12 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-31327</guid>
		<description>Trying to re-read this and I think there are maybe a couple of things going on here:

1) Dependencies - Avoiding domain having external dependencies, this was what the original question was about in relation to rule 3. You&#039;ve solved it by just having a collection on the entity, avoiding the need to go to the repository.
2) Handling any failures - Which is where events come in.

The two approaches can be used seperately and its the second one that I guess is more interesting...


&quot;The only problem is that the Domain Model needs to know that the service layer had a default catch clause so that it wouldn’t blow up. Otherwise, the service layer (or WCF, or nServiceBus) may end up flagging that message as a poison message (Read more about poison messages). You’d also have to be extremely careful about in which environments you used your Domain Model - in other words, your reuse is shot.&quot;

I see it a little differently. My domain classes allow other layers to ask questions, so you can ask can I do this? If the answer is no then you are given a nice Notification style object full of useful information explaining why the operation cannot be done. If however you ignore this nicety and try to proceed with the action anyway then we raise an exception (exceptions being useful when a method cannot do what it was designed to do). 

Exceptions are thus very rare and generally indicate a programming bug, you forgot to check that the operaiton was possible.

As you say if the caller does not pay attention and we do throw an exception then it might cause a failure, but then the equivalent of not catching an exception is not attaching to the error event handler and is it really better for the system to continue on after that happens?

You can also solve the retry/multiple responses issues, I&#039;ve definitely had exceptions that we caught and retried and bulked up errors into one exception and both worked well.

Despite using them my main problem with exceptions is that if you get all sorts of layers catching exceptions then it gets difficult to impose a policy that enforces consistent handling for particular types of exception. However this doesn&#039;t invalidate the whole approach.



&quot;In order to handle all aspects of the problem in as simple a way as possible, each part of the solution has to follow certain rules. By having the service layer only call one method on the domain model, transaction management, error handling, and correctness all “just work”.&quot;

Let me check I understand. Lets say that within the single domain method we need to coordinate some work accross two aggregates, each is being updated. The update to the first fails and we raise the appropriate FailureEvent, the domain service/method has already subscribed to this event and its handler ensures we don&#039;t continue with the update to the second aggregate. In addition the event is then also handled by the service layer. Does this sum up the approach?</description>
		<content:encoded><![CDATA[<p>Trying to re-read this and I think there are maybe a couple of things going on here:</p>
<p>1) Dependencies &#8211; Avoiding domain having external dependencies, this was what the original question was about in relation to rule 3. You&#8217;ve solved it by just having a collection on the entity, avoiding the need to go to the repository.<br />
2) Handling any failures &#8211; Which is where events come in.</p>
<p>The two approaches can be used seperately and its the second one that I guess is more interesting&#8230;</p>
<p>&#8220;The only problem is that the Domain Model needs to know that the service layer had a default catch clause so that it wouldn’t blow up. Otherwise, the service layer (or WCF, or nServiceBus) may end up flagging that message as a poison message (Read more about poison messages). You’d also have to be extremely careful about in which environments you used your Domain Model &#8211; in other words, your reuse is shot.&#8221;</p>
<p>I see it a little differently. My domain classes allow other layers to ask questions, so you can ask can I do this? If the answer is no then you are given a nice Notification style object full of useful information explaining why the operation cannot be done. If however you ignore this nicety and try to proceed with the action anyway then we raise an exception (exceptions being useful when a method cannot do what it was designed to do). </p>
<p>Exceptions are thus very rare and generally indicate a programming bug, you forgot to check that the operaiton was possible.</p>
<p>As you say if the caller does not pay attention and we do throw an exception then it might cause a failure, but then the equivalent of not catching an exception is not attaching to the error event handler and is it really better for the system to continue on after that happens?</p>
<p>You can also solve the retry/multiple responses issues, I&#8217;ve definitely had exceptions that we caught and retried and bulked up errors into one exception and both worked well.</p>
<p>Despite using them my main problem with exceptions is that if you get all sorts of layers catching exceptions then it gets difficult to impose a policy that enforces consistent handling for particular types of exception. However this doesn&#8217;t invalidate the whole approach.</p>
<p>&#8220;In order to handle all aspects of the problem in as simple a way as possible, each part of the solution has to follow certain rules. By having the service layer only call one method on the domain model, transaction management, error handling, and correctness all “just work”.&#8221;</p>
<p>Let me check I understand. Lets say that within the single domain method we need to coordinate some work accross two aggregates, each is being updated. The update to the first fails and we raise the appropriate FailureEvent, the domain service/method has already subscribed to this event and its handler ensures we don&#8217;t continue with the update to the second aggregate. In addition the event is then also handled by the service layer. Does this sum up the approach?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Morten Lyhr</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-31159</link>
		<dc:creator>Morten Lyhr</dc:creator>
		<pubDate>Sat, 06 Sep 2008 21:36:03 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-31159</guid>
		<description>I think your solution is complex and a bit over architected.

You can see my solution here: http://morten.lyhr.dk/2008/09/how-to-create-fully-encapsulated-and.html</description>
		<content:encoded><![CDATA[<p>I think your solution is complex and a bit over architected.</p>
<p>You can see my solution here: <a href="http://morten.lyhr.dk/2008/09/how-to-create-fully-encapsulated-and.html" rel="nofollow">http://morten.lyhr.dk/2008/09/how-to-create-fully-encapsulated-and.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elegant Code &#187; Decoupled Domain Models</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-30051</link>
		<dc:creator>Elegant Code &#187; Decoupled Domain Models</dc:creator>
		<pubDate>Tue, 26 Aug 2008 18:26:08 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-30051</guid>
		<description>[...] has written about How to create fully encapsulated Domain Models in the past (make sure to read the comments) and has further refined this approach in one of his [...]</description>
		<content:encoded><![CDATA[<p>[...] has written about How to create fully encapsulated Domain Models in the past (make sure to read the comments) and has further refined this approach in one of his [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Domain Events - Take 2</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-29941</link>
		<dc:creator>Domain Events - Take 2</dc:creator>
		<pubDate>Mon, 25 Aug 2008 13:41:05 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-29941</guid>
		<description>[...] previous post on how to create fully encapsulated domain models introduced the concept of events as a core pattern of communication from the domain back to the [...]</description>
		<content:encoded><![CDATA[<p>[...] previous post on how to create fully encapsulated domain models introduced the concept of events as a core pattern of communication from the domain back to the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-25433</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Fri, 20 Jun 2008 07:12:30 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-25433</guid>
		<description>One last thing, in terms of correctness under a multi-threaded execution environment when using Ayende&#039;s proposed solution - just mark the list with the [ThreadStatic] attribute.

It would be nice if there was a library that wrapped this up, wouldn&#039;t it?</description>
		<content:encoded><![CDATA[<p>One last thing, in terms of correctness under a multi-threaded execution environment when using Ayende&#8217;s proposed solution &#8211; just mark the list with the [ThreadStatic] attribute.</p>
<p>It would be nice if there was a library that wrapped this up, wouldn&#8217;t it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/comment-page-1/#comment-19648</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Sun, 23 Mar 2008 22:57:35 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/29/how-to-create-fully-encapsulated-domain-models/#comment-19648</guid>
		<description>Yoni,

I guess my question targeted your &quot;show user message&quot; comment, specifically the delegate part of it.

I&#039;m afraid that on the issue of performance/distribution we&#039;ll have to disagree - some things can&#039;t be solved after the fact. Now, as a result of my consulting practice, I may tend to see a larger percentage than most where that occurs. The result is usually a redesign/rewrite.

Not that I&#039;m against well designed, testable code mind you :)</description>
		<content:encoded><![CDATA[<p>Yoni,</p>
<p>I guess my question targeted your &#8220;show user message&#8221; comment, specifically the delegate part of it.</p>
<p>I&#8217;m afraid that on the issue of performance/distribution we&#8217;ll have to disagree &#8211; some things can&#8217;t be solved after the fact. Now, as a result of my consulting practice, I may tend to see a larger percentage than most where that occurs. The result is usually a redesign/rewrite.</p>
<p>Not that I&#8217;m against well designed, testable code mind you <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
