<?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: Strengthening your domain: Encapsulated collections</title>
	<atom:link href="http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Sun, 19 May 2013 03:22:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Josh Kodroff</title>
		<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/#comment-2234</link>
		<dc:creator>Josh Kodroff</dc:creator>
		<pubDate>Thu, 11 Nov 2010 17:29:07 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx#comment-2234</guid>
		<description>This article really helped me pimp up my domain model.  One thing, though...

I don&#039;t get how you can have &quot;private readonly IList&lt;Order&gt; _orders = new List&lt;Order&gt;();&quot; and still do lazy loading (at least without adding extra variables to track whether you&#039;ve tried to load the collection).  What&#039;s the solution for that?</description>
		<content:encoded><![CDATA[<p>This article really helped me pimp up my domain model.  One thing, though&#8230;</p>
<p>I don&#8217;t get how you can have &#8220;private readonly IList<order> _orders = new List</order><order>();&#8221; and still do lazy loading (at least without adding extra variables to track whether you&#8217;ve tried to load the collection).  What&#8217;s the solution for that?</order></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/#comment-2233</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Thu, 08 Apr 2010 12:21:42 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx#comment-2233</guid>
		<description>@Rhys

Perhaps you can answer, why _would_ I do this?  What does this extra code tax give me?  Keep in mind I don&#039;t care about anyone casting to IList&lt;T&gt; or something else like that.</description>
		<content:encoded><![CDATA[<p>@Rhys</p>
<p>Perhaps you can answer, why _would_ I do this?  What does this extra code tax give me?  Keep in mind I don&#8217;t care about anyone casting to IList<t> or something else like that.</t></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RhysC</title>
		<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/#comment-2232</link>
		<dc:creator>RhysC</dc:creator>
		<pubDate>Thu, 08 Apr 2010 02:35:07 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx#comment-2232</guid>
		<description>I dont want to harp on Jimmy, but why would you not just return an actual IEnum&lt;Order&gt; ?

public IEnumerable&lt;Order&gt; Orders { 
get 
{ 
    foreach(var o in _orders) 
     yield return o;
} 
}

Its a trival amount of additioonal code and gives you what you want. throw an extenion method to just make it return _orders.AsIEnumerable() and you are laughing :)</description>
		<content:encoded><![CDATA[<p>I dont want to harp on Jimmy, but why would you not just return an actual IEnum<order> ?</p>
<p>public IEnumerable</order><order> Orders {<br />
get<br />
{<br />
    foreach(var o in _orders)<br />
     yield return o;<br />
}<br />
}</p>
<p>Its a trival amount of additioonal code and gives you what you want. throw an extenion method to just make it return _orders.AsIEnumerable() and you are laughing <img src='http://lostechies.com/jimmybogard/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </order></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/#comment-2231</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Fri, 02 Apr 2010 20:25:51 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx#comment-2231</guid>
		<description>@Ryan

If there&#039;s a screen to allow removing an order line, sure!  The important thing here is to not expose the entire collection directly, but only the operations needed by the application.</description>
		<content:encoded><![CDATA[<p>@Ryan</p>
<p>If there&#8217;s a screen to allow removing an order line, sure!  The important thing here is to not expose the entire collection directly, but only the operations needed by the application.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Hartzog</title>
		<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/#comment-2230</link>
		<dc:creator>Ryan Hartzog</dc:creator>
		<pubDate>Fri, 02 Apr 2010 19:51:38 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx#comment-2230</guid>
		<description>I can see how the Customer Order relationship would not want to expose a RemoveOrder() method, but what about Order &gt; OrderLine?  In that instance the Order would publicly expose OrderLines() and RemoveOrderLine(OrderLine line) while keeping the AddOrderLine(OrderLine line) behavior internal?</description>
		<content:encoded><![CDATA[<p>I can see how the Customer Order relationship would not want to expose a RemoveOrder() method, but what about Order > OrderLine?  In that instance the Order would publicly expose OrderLines() and RemoveOrderLine(OrderLine line) while keeping the AddOrderLine(OrderLine line) behavior internal?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shane Courtrille</title>
		<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/#comment-2229</link>
		<dc:creator>Shane Courtrille</dc:creator>
		<pubDate>Wed, 31 Mar 2010 18:34:51 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx#comment-2229</guid>
		<description>Agreed with Markus.  Udi had a good post on the idea that almost everything needs to come from something existing.

</description>
		<content:encoded><![CDATA[<p>Agreed with Markus.  Udi had a good post on the idea that almost everything needs to come from something existing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/#comment-2228</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Tue, 23 Mar 2010 12:26:30 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx#comment-2228</guid>
		<description>@Craig

Typically, we make the DTOs contain all writable members, including lists and collections.  This is also what you&#039;d need to do with serializable types, for example.</description>
		<content:encoded><![CDATA[<p>@Craig</p>
<p>Typically, we make the DTOs contain all writable members, including lists and collections.  This is also what you&#8217;d need to do with serializable types, for example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/#comment-2227</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Mon, 22 Mar 2010 23:18:38 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx#comment-2227</guid>
		<description>This might not be the place to ask this but I am wondering how you would configure AutoMapper to map the readonly IEnumerable to a DTO&#039;s readonly IEnumerable? Or should the DTO just contain an IList or array?</description>
		<content:encoded><![CDATA[<p>This might not be the place to ask this but I am wondering how you would configure AutoMapper to map the readonly IEnumerable to a DTO&#8217;s readonly IEnumerable? Or should the DTO just contain an IList or array?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edin</title>
		<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/#comment-2226</link>
		<dc:creator>Edin</dc:creator>
		<pubDate>Thu, 11 Mar 2010 17:16:04 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx#comment-2226</guid>
		<description>@Jimmy 

I wasn&#039;t aware of this approach. Thanks a lot!</description>
		<content:encoded><![CDATA[<p>@Jimmy </p>
<p>I wasn&#8217;t aware of this approach. Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Markus Zywitza</title>
		<link>http://lostechies.com/jimmybogard/2010/03/10/strengthening-your-domain-encapsulated-collections/#comment-2225</link>
		<dc:creator>Markus Zywitza</dc:creator>
		<pubDate>Thu, 11 Mar 2010 15:30:54 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx#comment-2225</guid>
		<description>I&#039;d rather object against the internal AddOrder() method than agaionst IEnumerable. IEnumerable is a clear hands-off sign for modifying. 
But rather than have internal AddOrder, I would add 
Order CreateOrder() {...}
to Customer. I know that this is slightly less testable, because I cannot stub the Customer for testing, but it is also cleaner. I remember a post from Udi Dahan that emphasizes this method of creating objects in a domain model.</description>
		<content:encoded><![CDATA[<p>I&#8217;d rather object against the internal AddOrder() method than agaionst IEnumerable. IEnumerable is a clear hands-off sign for modifying.<br />
But rather than have internal AddOrder, I would add<br />
Order CreateOrder() {&#8230;}<br />
to Customer. I know that this is slightly less testable, because I cannot stub the Customer for testing, but it is also cleaner. I remember a post from Udi Dahan that emphasizes this method of creating objects in a domain model.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
