<?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: The Relationship Zoo</title>
	<atom:link href="http://nblumhardt.com/2010/01/the-relationship-zoo/feed/" rel="self" type="application/rss+xml" />
	<link>http://nblumhardt.com/2010/01/the-relationship-zoo/</link>
	<description></description>
	<lastBuildDate>Wed, 21 Jul 2010 08:01:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Nicholas Blumhardt</title>
		<link>http://nblumhardt.com/2010/01/the-relationship-zoo/comment-page-1/#comment-544</link>
		<dc:creator>Nicholas Blumhardt</dc:creator>
		<pubDate>Sun, 18 Jul 2010 23:03:11 +0000</pubDate>
		<guid isPermaLink="false">http://nblumhardt.com/?p=112#comment-544</guid>
		<description>Thanks Wim!</description>
		<content:encoded><![CDATA[<p>Thanks Wim!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wim Coenen</title>
		<link>http://nblumhardt.com/2010/01/the-relationship-zoo/comment-page-1/#comment-461</link>
		<dc:creator>Wim Coenen</dc:creator>
		<pubDate>Mon, 07 Jun 2010 21:30:53 +0000</pubDate>
		<guid isPermaLink="false">http://nblumhardt.com/?p=112#comment-461</guid>
		<description>I keep coming back to this epic post when I&#039;m thinking about DI. Great stuff!</description>
		<content:encoded><![CDATA[<p>I keep coming back to this epic post when I&#8217;m thinking about DI. Great stuff!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Autofac正式发布2.1版 - 自由、创新、研究、探索 - 博客园</title>
		<link>http://nblumhardt.com/2010/01/the-relationship-zoo/comment-page-1/#comment-289</link>
		<dc:creator>Autofac正式发布2.1版 - 自由、创新、研究、探索 - 博客园</dc:creator>
		<pubDate>Sat, 24 Apr 2010 12:02:30 +0000</pubDate>
		<guid isPermaLink="false">http://nblumhardt.com/?p=112#comment-289</guid>
		<description>[...] Metadata interrogation  &#160;&#160; 具体参看文章The Relationship Zoo. [...]</description>
		<content:encoded><![CDATA[<p>[...] Metadata interrogation  &#160;&#160; 具体参看文章The Relationship Zoo. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nRoute: Now, More Wholesome</title>
		<link>http://nblumhardt.com/2010/01/the-relationship-zoo/comment-page-1/#comment-253</link>
		<dc:creator>nRoute: Now, More Wholesome</dc:creator>
		<pubDate>Tue, 13 Apr 2010 23:36:35 +0000</pubDate>
		<guid isPermaLink="false">http://nblumhardt.com/?p=112#comment-253</guid>
		<description>[...] so-called Locator Adapters, this is inspired by Common Context Adapters concepts which is all about abstracting out the IoC container specifics and using higher-order dependencies. For example, consider if we want to lazy-load a resource from [...]</description>
		<content:encoded><![CDATA[<p>[...] so-called Locator Adapters, this is inspired by Common Context Adapters concepts which is all about abstracting out the IoC container specifics and using higher-order dependencies. For example, consider if we want to lazy-load a resource from [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Introducing Autofac 2.1 RTW : Nicholas Blumhardt</title>
		<link>http://nblumhardt.com/2010/01/the-relationship-zoo/comment-page-1/#comment-241</link>
		<dc:creator>Introducing Autofac 2.1 RTW : Nicholas Blumhardt</dc:creator>
		<pubDate>Sun, 11 Apr 2010 21:34:20 +0000</pubDate>
		<guid isPermaLink="false">http://nblumhardt.com/?p=112#comment-241</guid>
		<description>[...] For more information on relationship types, see the introductory article. [...]</description>
		<content:encoded><![CDATA[<p>[...] For more information on relationship types, see the introductory article. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Autofac 2.1 goes RC (the &#8220;me too!&#8221; release) : Nicholas Blumhardt</title>
		<link>http://nblumhardt.com/2010/01/the-relationship-zoo/comment-page-1/#comment-140</link>
		<dc:creator>Autofac 2.1 goes RC (the &#8220;me too!&#8221; release) : Nicholas Blumhardt</dc:creator>
		<pubDate>Wed, 10 Feb 2010 13:07:19 +0000</pubDate>
		<guid isPermaLink="false">http://nblumhardt.com/?p=112#comment-140</guid>
		<description>[...] Two new adapters for the zoo: [...]</description>
		<content:encoded><![CDATA[<p>[...] Two new adapters for the zoo: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Block</title>
		<link>http://nblumhardt.com/2010/01/the-relationship-zoo/comment-page-1/#comment-137</link>
		<dc:creator>Glenn Block</dc:creator>
		<pubDate>Mon, 08 Feb 2010 05:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://nblumhardt.com/?p=112#comment-137</guid>
		<description>Mark, i think you are missing one important aspect of metadata. It is not only used for fitering, it is also used for providing information that self-describes the export. For example it might provide category information. For example if you use Meta&lt;Lazy, FooMetadata&gt; or Lazy (in the MEF case) you are able to access information about Foo WITHOUT instantiating it. Having a magic policy that automatically applies a filter to the collection would be nice, but it doesn&#039;t suffice for the second capabillity I just mentioned.

On the coallescing of multiple Foos into a composite Foo, that also does not meet the use cases. Imagine you are pulling in menu actions that will displayed on a toolbar. The UI binds to the list of actions, it doesn&#039;t bind to a compose action. Each action is worked with individually. Composing the action would then mean that the UI sees them all as a single action, when they are not. Now if you are doing a chain of responsibility on the other hand, then having the components as a single would be very nice.</description>
		<content:encoded><![CDATA[<p>Mark, i think you are missing one important aspect of metadata. It is not only used for fitering, it is also used for providing information that self-describes the export. For example it might provide category information. For example if you use Meta&lt;Lazy, FooMetadata&gt; or Lazy (in the MEF case) you are able to access information about Foo WITHOUT instantiating it. Having a magic policy that automatically applies a filter to the collection would be nice, but it doesn&#8217;t suffice for the second capabillity I just mentioned.</p>
<p>On the coallescing of multiple Foos into a composite Foo, that also does not meet the use cases. Imagine you are pulling in menu actions that will displayed on a toolbar. The UI binds to the list of actions, it doesn&#8217;t bind to a compose action. Each action is worked with individually. Composing the action would then mean that the UI sees them all as a single action, when they are not. Now if you are doing a chain of responsibility on the other hand, then having the components as a single would be very nice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Blumhardt</title>
		<link>http://nblumhardt.com/2010/01/the-relationship-zoo/comment-page-1/#comment-133</link>
		<dc:creator>Nicholas Blumhardt</dc:creator>
		<pubDate>Sat, 06 Feb 2010 21:35:48 +0000</pubDate>
		<guid isPermaLink="false">http://nblumhardt.com/?p=112#comment-133</guid>
		<description>Mark, thanks for the thoughtful comment!

Enumerability, and its combination with Metadata, isn&#039;t a leaky abstraction when the identities of the individual injected components matter to the consuming component. You mentioned coalescing - instead of applying these adapters to the &lt;i&gt;consumer&lt;/i&gt; of the coalescer, they&#039;d be used to &lt;i&gt;implement&lt;/i&gt; the coalescer in a container-independent way. Likewise for the composite.

As a concrete example, instead of exposing all of the individual &quot;shape renderers&quot; to the different components in a drawing application, they&#039;d use a composite shape renderer that accepted a shape and dispatched it to the appropriate underlying &quot;atomic&quot; renderer. It is the implementation of the composite renderer that needs enough information to correctly dispatch the shape.

Agreeing on small building blocks like these mean that more complex composition patterns like these two you&#039;ve mentioned can be defined in an application-specific way. Deciding on a common specification for implementing these patterns in their entirety would be orders of magnitude harder than the task before us here. (Imagine trying to write a common spec for how rendering an unknown shape would proceed in the above example.)

Regarding ownership/component release - the general problem here is that in order for the container to manage lifetime &quot;for us&quot; it must have some sense of where a Unit of Work begins and ends. Most current approaches require container-specific configuration based on ambient state and application lifecycle events. It is not always possible to associate a unit of work in an application with these.

On Lazy and inheritance - I agree that the transparent proxying approach is nice, but not all services are expressed as interfaces or virtualised ABCs. Providing the transparent mechanism via configuration is a nice addition to a baseline &#039;portable&#039; alternative like Lazy.

Your ideas on expressing metadata selection as a Func/Predicate structure are really interesting - I&#039;m glad you&#039;ve popped up on the CCA forum, this will be a fantastic alternative to consider when we get to selection-from-alternatives :)</description>
		<content:encoded><![CDATA[<p>Mark, thanks for the thoughtful comment!</p>
<p>Enumerability, and its combination with Metadata, isn&#8217;t a leaky abstraction when the identities of the individual injected components matter to the consuming component. You mentioned coalescing &#8211; instead of applying these adapters to the <i>consumer</i> of the coalescer, they&#8217;d be used to <i>implement</i> the coalescer in a container-independent way. Likewise for the composite.</p>
<p>As a concrete example, instead of exposing all of the individual &#8220;shape renderers&#8221; to the different components in a drawing application, they&#8217;d use a composite shape renderer that accepted a shape and dispatched it to the appropriate underlying &#8220;atomic&#8221; renderer. It is the implementation of the composite renderer that needs enough information to correctly dispatch the shape.</p>
<p>Agreeing on small building blocks like these mean that more complex composition patterns like these two you&#8217;ve mentioned can be defined in an application-specific way. Deciding on a common specification for implementing these patterns in their entirety would be orders of magnitude harder than the task before us here. (Imagine trying to write a common spec for how rendering an unknown shape would proceed in the above example.)</p>
<p>Regarding ownership/component release &#8211; the general problem here is that in order for the container to manage lifetime &#8220;for us&#8221; it must have some sense of where a Unit of Work begins and ends. Most current approaches require container-specific configuration based on ambient state and application lifecycle events. It is not always possible to associate a unit of work in an application with these.</p>
<p>On Lazy and inheritance &#8211; I agree that the transparent proxying approach is nice, but not all services are expressed as interfaces or virtualised ABCs. Providing the transparent mechanism via configuration is a nice addition to a baseline &#8216;portable&#8217; alternative like Lazy.</p>
<p>Your ideas on expressing metadata selection as a Func/Predicate structure are really interesting &#8211; I&#8217;m glad you&#8217;ve popped up on the CCA forum, this will be a fantastic alternative to consider when we get to selection-from-alternatives <img src='http://nblumhardt.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Seemann</title>
		<link>http://nblumhardt.com/2010/01/the-relationship-zoo/comment-page-1/#comment-131</link>
		<dc:creator>Mark Seemann</dc:creator>
		<pubDate>Fri, 05 Feb 2010 13:04:06 +0000</pubDate>
		<guid isPermaLink="false">http://nblumhardt.com/?p=112#comment-131</guid>
		<description>This is a good and fairly inclusive enumeration of possible dependency relationship types.

I think some of them are valuable as more explicit dependency relationships, whereas others are important DI Container creation strategies, but not necessarily as explict Adapters. Let&#039;s look at each one:

Func&lt;B&gt;: This is simply an Abstract Factory, which is one of the most important DI patterns available. It allows us to bridge the gap where a consumer needs to create an arbitrary number of abstract instances managed by the container. Some DI Containers can automatically create such strongly typed Factories at run-time based on registered parts and the type of the Abstract Factory, but it would be very valuable if they all could.

Func: This is also an Abstract Factory, but an even more important variation, as it bridges the gap where we need to combine long-lived services (B&#039;s dependencies) with run-time values (X and Y). In reality, we will need Func, Func, Func etc. It would be even more valuable if we could agree on a Common Context Adapter that allows each DI Container to automatically emit an implementation that does this. I have more thoughts on this, but let&#039;s continue that discussion over at the Common Context Adapters project :)

IEnumerable&lt;B&gt;: This is another common DI pattern, but in many cases I consider it a Leaky Abstraction if a consumer explicitly requests it like this. It would be more correct to simply request B and then configure the container to return a CompositeB or a CoalescingB (both implement B), thus encapsulating the knowledge that there may be more than one. Once again, it would be valuable if a DI Container could automatically emit these. It ought to be doable for Composites, but I&#039;m not sure about Coalescers...

Owned&lt;B&gt;: This one I&#039;m not quite sure of. As a general principle, I consider DI to imply that we are  giving up on controlling the lifetime of dependencies, yet here we attempt to do so anyway. It feels like a Leaky Abstraction as well, but I presume that for a long-lived service that consumes short-lived dependencies (created by Func), this provides a mechanism to signal the release of the dependency (and thereby allowing for potential disposal). I have to think about this some more.

Lazy&lt;B&gt;: This can be a valid lifetime strategy, although I consider it a bit of a corner case. I&#039;ve already described my thoughts on this approach here: http://blog.ploeh.dk/2010/01/20/RebuttalConstructorOverinjectionAntipattern.aspx. In summary, I find it valuable if a DI Container supports this lifetime strategy, but I consider it a Leaky Abstraction to take a dependency on Lazy&lt;B&gt;. Rather, Lazy&lt;B&gt; ought to be a lifetime strategy that we can configure in the container so that when A requests B, they really get a Lazy&lt;B&gt; (which means that Lazy&lt;B&gt; must derive from B).

Meta&lt;B&gt;: This is basically just a Tuple, but with a bite more intention-revealing name. Once more, my knee-jerk reaction is that if a consumer requests such a dependency it would be a Leaky Abstraction. A better approach would be to model the dependency either by the Tester-Doer pattern or try to adhere more to the Hollywood Principle. But once again, as seen from the Container&#039;s side, it would be awesome if we could specify complex rules that injects dependencies based on some sort of context. I would rather want to see X expressed in terms of the Specification pattern (basically a Predicate). At this point, we are very close to a parameterized Abstract Factory - it&#039;s Func where S is a Specification.</description>
		<content:encoded><![CDATA[<p>This is a good and fairly inclusive enumeration of possible dependency relationship types.</p>
<p>I think some of them are valuable as more explicit dependency relationships, whereas others are important DI Container creation strategies, but not necessarily as explict Adapters. Let&#8217;s look at each one:</p>
<p>Func&lt;B&gt;: This is simply an Abstract Factory, which is one of the most important DI patterns available. It allows us to bridge the gap where a consumer needs to create an arbitrary number of abstract instances managed by the container. Some DI Containers can automatically create such strongly typed Factories at run-time based on registered parts and the type of the Abstract Factory, but it would be very valuable if they all could.</p>
<p>Func: This is also an Abstract Factory, but an even more important variation, as it bridges the gap where we need to combine long-lived services (B&#8217;s dependencies) with run-time values (X and Y). In reality, we will need Func, Func, Func etc. It would be even more valuable if we could agree on a Common Context Adapter that allows each DI Container to automatically emit an implementation that does this. I have more thoughts on this, but let&#8217;s continue that discussion over at the Common Context Adapters project <img src='http://nblumhardt.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>IEnumerable&lt;B&gt;: This is another common DI pattern, but in many cases I consider it a Leaky Abstraction if a consumer explicitly requests it like this. It would be more correct to simply request B and then configure the container to return a CompositeB or a CoalescingB (both implement B), thus encapsulating the knowledge that there may be more than one. Once again, it would be valuable if a DI Container could automatically emit these. It ought to be doable for Composites, but I&#8217;m not sure about Coalescers&#8230;</p>
<p>Owned&lt;B&gt;: This one I&#8217;m not quite sure of. As a general principle, I consider DI to imply that we are  giving up on controlling the lifetime of dependencies, yet here we attempt to do so anyway. It feels like a Leaky Abstraction as well, but I presume that for a long-lived service that consumes short-lived dependencies (created by Func), this provides a mechanism to signal the release of the dependency (and thereby allowing for potential disposal). I have to think about this some more.</p>
<p>Lazy&lt;B&gt;: This can be a valid lifetime strategy, although I consider it a bit of a corner case. I&#8217;ve already described my thoughts on this approach here: <a href="http://blog.ploeh.dk/2010/01/20/RebuttalConstructorOverinjectionAntipattern.aspx" rel="nofollow">http://blog.ploeh.dk/2010/01/20/RebuttalConstructorOverinjectionAntipattern.aspx</a>. In summary, I find it valuable if a DI Container supports this lifetime strategy, but I consider it a Leaky Abstraction to take a dependency on Lazy&lt;B&gt;. Rather, Lazy&lt;B&gt; ought to be a lifetime strategy that we can configure in the container so that when A requests B, they really get a Lazy&lt;B&gt; (which means that Lazy&lt;B&gt; must derive from B).</p>
<p>Meta&lt;B&gt;: This is basically just a Tuple, but with a bite more intention-revealing name. Once more, my knee-jerk reaction is that if a consumer requests such a dependency it would be a Leaky Abstraction. A better approach would be to model the dependency either by the Tester-Doer pattern or try to adhere more to the Hollywood Principle. But once again, as seen from the Container&#8217;s side, it would be awesome if we could specify complex rules that injects dependencies based on some sort of context. I would rather want to see X expressed in terms of the Specification pattern (basically a Predicate). At this point, we are very close to a parameterized Abstract Factory &#8211; it&#8217;s Func where S is a Specification.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Blumhardt</title>
		<link>http://nblumhardt.com/2010/01/the-relationship-zoo/comment-page-1/#comment-128</link>
		<dc:creator>Nicholas Blumhardt</dc:creator>
		<pubDate>Mon, 01 Feb 2010 10:50:30 +0000</pubDate>
		<guid isPermaLink="false">http://nblumhardt.com/?p=112#comment-128</guid>
		<description>Those two (er, three) are pretty challenging and I&#039;ve been thinking about them more lately. Although the .NET type system can&#039;t declaratively express metadata constraints in a signature, we&#039;re not in a completely hopeless situation unless you need to do rejection. By using IQueryable of a metadata-enabled type as an adapter, the container gets the declaratively-specified requirements via the query. This opens a few doors to dynamic dependency satisfaction and prevents unnecessary instantiation of the components.

(BTW, I only realised recently - if the dependency is on IQueryable&lt;Meta&lt;T, TMetadata&gt;&gt;, despite the fact that Meta&lt;T, TMetadata&gt; is not lazy, the appropriate component/s can be selected without instantiating others unnecessarily.)</description>
		<content:encoded><![CDATA[<p>Those two (er, three) are pretty challenging and I&#8217;ve been thinking about them more lately. Although the .NET type system can&#8217;t declaratively express metadata constraints in a signature, we&#8217;re not in a completely hopeless situation unless you need to do rejection. By using IQueryable of a metadata-enabled type as an adapter, the container gets the declaratively-specified requirements via the query. This opens a few doors to dynamic dependency satisfaction and prevents unnecessary instantiation of the components.</p>
<p>(BTW, I only realised recently &#8211; if the dependency is on IQueryable&lt;Meta&lt;T, TMetadata>>, despite the fact that Meta&lt;T, TMetadata> is not lazy, the appropriate component/s can be selected without instantiating others unnecessarily.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
