<?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: Multiple-inheritance, composition and single responsibility principle in .NET</title>
	<atom:link href="http://damieng.com/blog/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net/feed" rel="self" type="application/rss+xml" />
	<link>http://damieng.com/blog/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=multiple-inheritance-composition-and-single-responsibility-principle-in-net</link>
	<description>A .NET developer in Redmond</description>
	<lastBuildDate>Tue, 31 Aug 2010 00:16:37 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Stealf</title>
		<link>http://damieng.com/blog/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net#comment-27741</link>
		<dc:creator>Stealf</dc:creator>
		<pubDate>Wed, 14 Oct 2009 07:38:24 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net.aspx#comment-27741</guid>
		<description>This is a bit of a late reply but I had essentially the same idea as this and agree that it would be a great addition to the language. 

http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/5120d5ef-97ec-4de6-ab6c-9a7b5dfc50de</description>
		<content:encoded><![CDATA[<p>This is a bit of a late reply but I had essentially the same idea as this and agree that it would be a great addition to the language. </p>
<p><a href="http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/5120d5ef-97ec-4de6-ab6c-9a7b5dfc50de" rel="nofollow">http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/5120d5ef-97ec-4de6-ab6c-9a7b5dfc50de</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net#comment-5529</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Tue, 11 Dec 2007 13:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net.aspx#comment-5529</guid>
		<description>What I&#039;m proposing with this post is compiler magic that would signal that an interface a class claims to support should be automatically wired up to a private instance variable where no specific implementation of a method or property exists in the class.

Having a get method isn&#039;t any better than a read only property, I was just closely following what the IEnumerable / IEnumerator pattern is to see what the result would look like.

I think we are after the same thing.  We want to be able to define a class, say it supports interface X and that we will be forwarding all methods and properties for that interface to our own private method except any we specifically write - in our case Add.

Other alternatives to the specific Add on collection problem you mention would be to force the collection property to be of a &lt;a href=&quot;http://damieng.com/blog/2006/06/14/observing_change_events_on_a_listt&quot; rel=&quot;nofollow&quot;&gt;listening type&lt;/a&gt; we can hook into or to internally hold the concrete collection but expose it out through a proxy object on one of our properties that calls us back using internal methods.

[)amien</description>
		<content:encoded><![CDATA[<p>What I&#8217;m proposing with this post is compiler magic that would signal that an interface a class claims to support should be automatically wired up to a private instance variable where no specific implementation of a method or property exists in the class.</p>
<p>Having a get method isn&#8217;t any better than a read only property, I was just closely following what the IEnumerable / IEnumerator pattern is to see what the result would look like.</p>
<p>I think we are after the same thing.  We want to be able to define a class, say it supports interface X and that we will be forwarding all methods and properties for that interface to our own private method except any we specifically write &#8211; in our case Add.</p>
<p>Other alternatives to the specific Add on collection problem you mention would be to force the collection property to be of a <a href="http://damieng.com/blog/2006/06/14/observing_change_events_on_a_listt" rel="nofollow">listening type</a> we can hook into or to internally hold the concrete collection but expose it out through a proxy object on one of our properties that calls us back using internal methods.</p>
<p>[)amien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Chapman</title>
		<link>http://damieng.com/blog/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net#comment-5526</link>
		<dc:creator>John Chapman</dc:creator>
		<pubDate>Tue, 11 Dec 2007 12:51:36 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net.aspx#comment-5526</guid>
		<description>I&#039;m failing to see the big accomplishments of this post.  A big issue to me is the fact that when you don&#039;t implement the interface you lose your ability to validate and monitor the actions taking place with the collection.  If someone calls Add() your class doesn&#039;t have any hooks to validate that added reference.  I think in this case actually implementing the interface on your class is relatively minor yet offers a lot of added benefit, such as being able to reject invalid assignments.

Plus, I was confused by something else.  How is using a read only property any different from using a get method to return the collection?  I fail to see how one approach is superior to the other.  They both compile down to the exact same thing.  The property becomes a get_ method and the method stays as a method of your name.  How is this any different?  I hope you don&#039;t mean the names are different so it doesn&#039;t have to be a list of product prices.  If that is the concern change the property to List, and you have the same result.  Is there something I&#039;m missing?</description>
		<content:encoded><![CDATA[<p>I&#8217;m failing to see the big accomplishments of this post.  A big issue to me is the fact that when you don&#8217;t implement the interface you lose your ability to validate and monitor the actions taking place with the collection.  If someone calls Add() your class doesn&#8217;t have any hooks to validate that added reference.  I think in this case actually implementing the interface on your class is relatively minor yet offers a lot of added benefit, such as being able to reject invalid assignments.</p>
<p>Plus, I was confused by something else.  How is using a read only property any different from using a get method to return the collection?  I fail to see how one approach is superior to the other.  They both compile down to the exact same thing.  The property becomes a get_ method and the method stays as a method of your name.  How is this any different?  I hope you don&#8217;t mean the names are different so it doesn&#8217;t have to be a list of product prices.  If that is the concern change the property to List, and you have the same result.  Is there something I&#8217;m missing?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: steve</title>
		<link>http://damieng.com/blog/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net#comment-1961</link>
		<dc:creator>steve</dc:creator>
		<pubDate>Tue, 07 Aug 2007 00:26:24 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net.aspx#comment-1961</guid>
		<description>Hey, and you&#039;ve found a use for the &#039;goto&#039; keyword again. That in itself has to be a positive thing ;)&lt;br /&gt;&lt;br /&gt;I think like all mantras the &#039;compose over inherit&#039; principle is correct in moderation. There are plenty of scenarios where composition leads to harder to maintain code, simply because in just about all languages it has to be manually wired up. This is of course its power as well, and I&#039;m not sure you can get the full benefit of the technique without incurring this. At the very least I think you&#039;d need to be able to direct the delegation via a factory method for the contained object (lazy creation) to avoid hard-coding the composed type.&lt;br /&gt;&lt;br /&gt;Many modern C++ techniques also echew inheritence in favour of templated composition through &lt;a href=&quot;http://en.wikipedia.org/wiki/Policy-based_design&quot;&gt;Policy Based Design&lt;/a&gt;. Again this works very well for some things, particularly low-level utility classes as opposed to higher-evel library APIs. Each technique has its place.</description>
		<content:encoded><![CDATA[<p>Hey, and you&#8217;ve found a use for the &#8216;goto&#8217; keyword again. That in itself has to be a positive thing ;)</p>
<p>I think like all mantras the &#8216;compose over inherit&#8217; principle is correct in moderation. There are plenty of scenarios where composition leads to harder to maintain code, simply because in just about all languages it has to be manually wired up. This is of course its power as well, and I&#8217;m not sure you can get the full benefit of the technique without incurring this. At the very least I think you&#8217;d need to be able to direct the delegation via a factory method for the contained object (lazy creation) to avoid hard-coding the composed type.</p>
<p>Many modern C++ techniques also echew inheritence in favour of templated composition through <a href="http://en.wikipedia.org/wiki/Policy-based_design">Policy Based Design</a>. Again this works very well for some things, particularly low-level utility classes as opposed to higher-evel library APIs. Each technique has its place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rik Hemsley</title>
		<link>http://damieng.com/blog/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net#comment-1960</link>
		<dc:creator>Rik Hemsley</dc:creator>
		<pubDate>Tue, 07 Aug 2007 00:11:15 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2007/08/06/multiple-inheritance-composition-and-single-responsibility-principle-in-net.aspx#comment-1960</guid>
		<description>You could call a static method on another class from your ctor. This method would add simple versions of the IList methods where they don&#039;t already exist.&lt;br /&gt;&lt;br /&gt;This breaks Intellisense and might destabilise the universe.&lt;br /&gt;&lt;br /&gt;I can&#039;t think of a better way to do it (in a not-exactly-dynamic language). Have you seen an implementation elsewhere?&lt;br /&gt;</description>
		<content:encoded><![CDATA[<p>You could call a static method on another class from your ctor. This method would add simple versions of the IList methods where they don&#8217;t already exist.</p>
<p>This breaks Intellisense and might destabilise the universe.</p>
<p>I can&#8217;t think of a better way to do it (in a not-exactly-dynamic language). Have you seen an implementation elsewhere?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
