<?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 for Peter-John R. Lightfoot</title>
	<atom:link href="http://pj.lightfoot.cc/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://pj.lightfoot.cc</link>
	<description>Programmer &#124; Architect &#124; Solutionist</description>
	<lastBuildDate>Tue, 20 Dec 2011 13:28:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>Comment on A base implementation of System.IDisposable by Brendon</title>
		<link>http://pj.lightfoot.cc/2011/12/a-base-implementation-of-system-idisposable/#comment-364</link>
		<dc:creator>Brendon</dc:creator>
		<pubDate>Tue, 20 Dec 2011 13:28:48 +0000</pubDate>
		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=431#comment-364</guid>
		<description>Thanks for taking the time to provide such a detailed response.

Yeah, &quot;may derive&quot; was the correct interpretation. Good explanation - it&#039;s quite clear now.</description>
		<content:encoded><![CDATA[<p>Thanks for taking the time to provide such a detailed response.</p>
<p>Yeah, &#8220;may derive&#8221; was the correct interpretation. Good explanation &#8211; it&#8217;s quite clear now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on A base implementation of System.IDisposable by Peter-John</title>
		<link>http://pj.lightfoot.cc/2011/12/a-base-implementation-of-system-idisposable/#comment-362</link>
		<dc:creator>Peter-John</dc:creator>
		<pubDate>Mon, 19 Dec 2011 14:02:33 +0000</pubDate>
		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=431#comment-362</guid>
		<description>Hi Brendon, thanks for the valuable question! 

Yes, the class is intended to be inherited (as will be illustrated in my follow-up post). But, in an of itself that should not clash with any OO design concepts, and neither does any base class determine the defining feature of its derived classes. When we talk OO, we say that derived classes &quot;specialize&quot; the type of the base class, that they are &quot;more specialized&quot; than the base, or that the base class is &quot;more general&quot; or &quot;less specific&quot; than the derived classes. As such, the base class can at most determine some characteristics of the derived class. There is in principle no limit on how the derived class can extend the base.

Nevertheless your alarm is quite rightly placed. In this particular case one has to consider the derived class in detail, before deciding to inherit from Disposable. If there is contention in that the class may also rightly derive from a different base, then one has done well to pause.

If Disposable was at all difficult to implement or widely used, I&#039;m sure the framework would have had its own implementation. But, while there are no doubt valid reasons for the framework to only provide the IDisposable interface, that does not imply that we MUST always implement the interface from scratch.

To conclude (and hopefully satisfy your query) - this kind of abstract base class is probably not something that you&#039;d ship as part of a public library, but can be a very useful addition to an internal framework, where you are at once the publisher and consumer of the class. In such a scenario you are free to both inherit the base functionality on the occasions where you have classes that are in themselves of a fairly primitive nature (does not inherit base functionality - ironically these are usually the ones where you&#039;d want IDisposable functionality), or alternatively simply use the code as a template for the manual implementation of the IDisposable interface (i.e. for illustration purposes).

Just an afterthought about the possible intent of your question... I would say classes &quot;may&quot; derive from it, not that classes &quot;should&quot; derive from it (i.e. don&#039;t simply make all classes disposable). Also, classes deriving from it (and for that matter any classes implementing IDisposable) shouldn&#039;t necessarily add a finalizer unless it&#039;s specifically required by the state or owned objects of that class. Finally, when a class does implement IDisposable or inherit this base, if it defines a finalizer it should be sealed, as further consumers will not necessarily be aware of the finalizer and may add additional finalizers into the hierarchy, which would start to make the derived object very expensive to use.</description>
		<content:encoded><![CDATA[<p>Hi Brendon, thanks for the valuable question! </p>
<p>Yes, the class is intended to be inherited (as will be illustrated in my follow-up post). But, in an of itself that should not clash with any OO design concepts, and neither does any base class determine the defining feature of its derived classes. When we talk OO, we say that derived classes &#8220;specialize&#8221; the type of the base class, that they are &#8220;more specialized&#8221; than the base, or that the base class is &#8220;more general&#8221; or &#8220;less specific&#8221; than the derived classes. As such, the base class can at most determine some characteristics of the derived class. There is in principle no limit on how the derived class can extend the base.</p>
<p>Nevertheless your alarm is quite rightly placed. In this particular case one has to consider the derived class in detail, before deciding to inherit from Disposable. If there is contention in that the class may also rightly derive from a different base, then one has done well to pause.</p>
<p>If Disposable was at all difficult to implement or widely used, I&#8217;m sure the framework would have had its own implementation. But, while there are no doubt valid reasons for the framework to only provide the IDisposable interface, that does not imply that we MUST always implement the interface from scratch.</p>
<p>To conclude (and hopefully satisfy your query) &#8211; this kind of abstract base class is probably not something that you&#8217;d ship as part of a public library, but can be a very useful addition to an internal framework, where you are at once the publisher and consumer of the class. In such a scenario you are free to both inherit the base functionality on the occasions where you have classes that are in themselves of a fairly primitive nature (does not inherit base functionality &#8211; ironically these are usually the ones where you&#8217;d want IDisposable functionality), or alternatively simply use the code as a template for the manual implementation of the IDisposable interface (i.e. for illustration purposes).</p>
<p>Just an afterthought about the possible intent of your question&#8230; I would say classes &#8220;may&#8221; derive from it, not that classes &#8220;should&#8221; derive from it (i.e. don&#8217;t simply make all classes disposable). Also, classes deriving from it (and for that matter any classes implementing IDisposable) shouldn&#8217;t necessarily add a finalizer unless it&#8217;s specifically required by the state or owned objects of that class. Finally, when a class does implement IDisposable or inherit this base, if it defines a finalizer it should be sealed, as further consumers will not necessarily be aware of the finalizer and may add additional finalizers into the hierarchy, which would start to make the derived object very expensive to use.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on A base implementation of System.IDisposable by Brendon</title>
		<link>http://pj.lightfoot.cc/2011/12/a-base-implementation-of-system-idisposable/#comment-361</link>
		<dc:creator>Brendon</dc:creator>
		<pubDate>Mon, 19 Dec 2011 09:39:44 +0000</pubDate>
		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=431#comment-361</guid>
		<description>Hi Peter-John

Interesting post and I like the website. Perhaps this is a silly question, but what is the purpose of the Disposable class - i.e. is it for illustration purposes, or should classes derive from it? In the latter case, would it not clash with OO design concepts in many cases - as you can&#039;t have multiple inheritance, you&#039;re basically stating that the defining feature of the derived class is that it&#039;s disposable?

Thanks</description>
		<content:encoded><![CDATA[<p>Hi Peter-John</p>
<p>Interesting post and I like the website. Perhaps this is a silly question, but what is the purpose of the Disposable class &#8211; i.e. is it for illustration purposes, or should classes derive from it? In the latter case, would it not clash with OO design concepts in many cases &#8211; as you can&#8217;t have multiple inheritance, you&#8217;re basically stating that the defining feature of the derived class is that it&#8217;s disposable?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>

