<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>On aliasing the Dispose name...</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx</link><description>Michael argues that the guideline we have around using a customized name for the Dispose method is a bad idea because it adds developer confusion. This is a reasonable argument, and one that heavy hitters such as Jeffrey Richter buy into as well, so it</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>RE: On aliasing the Dispose name...</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#50128</link><pubDate>Mon, 07 Jul 2003 06:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50128</guid><dc:creator>JosephCooney</dc:creator><description>re: Close vs. Dispose...what about the SqlConnection class? It implements Close() and Dispose(). From looking at the dis-assembly it looks like Dispose() calls Close() but not the other way around (but that could just be me). I understand this may have been done for connection pooling reasons, but is still makes things somewhat confusing.</description></item><item><title>RE: On aliasing the Dispose name...</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#50129</link><pubDate>Mon, 07 Jul 2003 09:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50129</guid><dc:creator>Michael Bouck</dc:creator><description>Didn't know I was in the Jeff Richter camp! :-)  I'm OK with this argument except for the fact that goal 1 is relying completely on the developer to &amp;quot;do the right thing&amp;quot; (i.e. implementing Dispose() explicitly and privately).  I don't know about you, but I have seen best practices thrown out the window too many times to count (that's why smart pointers were so cool, right?  It automatically saved the guy who didn't remember to AddRef()/Release() his interfaces (in most cases)).  I've already seen violations of this rule in third party code and boy is it ugly when I see Dispose(), Close(), Release(), Free(), etc.  all defined as public!  Mostly though, and I might be being a bit pedantic, it's the &amp;quot;purity thing&amp;quot; (goal 3) that appeals to me.  To be able to say, categorically, that DF is accomplished, always, in one way makes life easier on everyone.  Sure, the VB guy is going to be a bit confused at first but I would argue he's going to be much more confused getting used to OOP in the first place.  It's more orthogonal to see a random class in the object viewer which implements IDisposable and know that there is exactally one way to get rid of it.

Having said that, if the majority still thinks this is the right way to go, I'd like to propose that the compiler at least emit a warning if Dispose() is aliased by a public method and is not explicitly implemeneted privately.  FxCop isn't sufficient in my opinion, because the guy that is abusing goal 1 probably isn't running FxCop either...
   </description></item><item><title>RE: On aliasing the Dispose name...</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#50130</link><pubDate>Mon, 07 Jul 2003 10:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50130</guid><dc:creator>Matthew Adams</dc:creator><description>By an extraordinary coincidence, I was having this converstaion on Friday. Personally, I think that Dispose() is a big problem in the developer community at large. Whiilst it does provide a form of deterministic finalization, people associate the term 'finalize' with 'garbage collect', which Dispose() most certainly does not. 

Implementing Dispose() as an under the covers method to support the 'using' idiom is fine, but, otherwise, you should really provide an explicitly documented life-cycle management policy for your object, and a separate idiom is best for that (and hence *at least* a separate method). Personally, I prefer an Acquire/Release approach from an entirely separate manager for the limited resource, and Ian suggested a duration-of-work approach, rather like DataAdapter.Fill().

Whichever way you cut it, Dispose() is essential, when it is absolutely essential, but it is over-used and badly understood at the moment. And that makes it a dangerous tool.</description></item><item><title>RE: On aliasing the Dispose name...</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#50131</link><pubDate>Tue, 08 Jul 2003 08:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50131</guid><dc:creator>Mickey Williams</dc:creator><description>Re: The earlier comment about Close vs. Dispose in SqlConnection...
In SqlConnection, Close and Dispose are not the same thing. As expected, Dispose completely releases resources, and the instance can't be used for anything ever again, try it and you'll get an ObjectDisposed exception. On the other hand, SqlConnection.Close is similar, but enables you to reuse the same instance later. Dispose depends on Close to cleanup.</description></item><item><title>RE: On aliasing the Dispose name...</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#50132</link><pubDate>Wed, 09 Jul 2003 06:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50132</guid><dc:creator>Jeffrey Richter</dc:creator><description>Actually, I'm not opposed to FileStream offerring Close. What I am opposed to is &amp;quot;hiding&amp;quot; Dispose and forcing the FileStream variable to be cast to IDisposable in order to call Dispose. I'd be OK if both Close and Dispose were _equally_ callable.</description></item><item><title>RE: On aliasing the Dispose name...</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#50133</link><pubDate>Fri, 11 Jul 2003 04:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50133</guid><dc:creator>Frank Hileman</dc:creator><description>I agree mostly with Jeffrey. Hiding Dispose just introduces unnecessary inconsistencies. But if people have to learn to use the .net framework, they will have to learn about Dispose, and as soon as they have learned, redundant functions such as Close just add confusion.</description></item><item><title>Disposal Anxiety</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#253664</link><pubDate>Mon, 08 Nov 2004 02:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:253664</guid><dc:creator>K. Scott Allen's Blog</dc:creator><description /></item><item><title>Disposal Anxiety</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#253669</link><pubDate>Mon, 08 Nov 2004 02:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:253669</guid><dc:creator>K. Scott Allen's Blog</dc:creator><description /></item><item><title>C#中Dispose和Close的区别！</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#1477518</link><pubDate>Tue, 16 Jan 2007 13:06:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1477518</guid><dc:creator>Kevin Wan</dc:creator><description>&lt;p&gt;当我们开发C#代码的时候，经常碰到一个问题，有些class提供Close()，有些class提供Dispose()，而且有些class里面还提供了Dispose(bool)，那么Dispose和Close到底有什么区别？&lt;/p&gt;
</description></item><item><title>[转载]C#中Dispose和Close的区别</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#2686280</link><pubDate>Thu, 17 May 2007 06:16:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2686280</guid><dc:creator>夏亚兵</dc:creator><description>&lt;p&gt;当我们开发C#代码的时候，经常碰到一个问题，有些class提供Close()，有些class提供Dispose()，那么Dispose和Close到底有什么区别？首先，Dispose和Close基本上...&lt;/p&gt;
</description></item><item><title>C#中Dispose和Close的区别。</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#3454580</link><pubDate>Fri, 22 Jun 2007 10:27:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3454580</guid><dc:creator>勤勤同学</dc:creator><description>&lt;p&gt;当我们开发C#代码的时候，经常碰到一个问题，有些class提供Close()，有些class提供Dispose()，那么Dispose和Close到底有什么区别？&lt;/p&gt;
</description></item><item><title>[转]C#中Dispose和Close的区别！</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#8116791</link><pubDate>Sun, 09 Mar 2008 12:09:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8116791</guid><dc:creator>菩提树下的杨过</dc:creator><description>&lt;p&gt;原文地址:&lt;a rel="nofollow" target="_new" href="http://www.cnblogs.com/kevinwan/archive/2007/01/16/621869.html"&gt;http://www.cnblogs.com/kevinwan/archive/2007/01/16/621869.html&lt;/a&gt; 当我们开发C#代码的时候，经常碰到一个问题，有些clas...&lt;/p&gt;
</description></item><item><title>正确实现IDisposable  Dispose和Close的区别</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#8352857</link><pubDate>Thu, 03 Apr 2008 04:48:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8352857</guid><dc:creator>ljsql</dc:creator><description>&lt;p&gt;正确实现IDisposable Dispose和Close的区别&lt;/p&gt;
</description></item><item><title>???????????????  &amp;raquo; Blog Archive   &amp;raquo; C#???Dispose???Close????????? | ????????????</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#8550535</link><pubDate>Sun, 25 May 2008 06:25:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8550535</guid><dc:creator>???????????????  &amp;raquo; Blog Archive   &amp;raquo; C#???Dispose???Close????????? | ????????????</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.zuu.cn/1958.html"&gt;http://www.zuu.cn/1958.html&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>C#???Dispose???Close????????? | ???????????????</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#9478963</link><pubDate>Sun, 15 Mar 2009 16:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9478963</guid><dc:creator>C#???Dispose???Close????????? | ???????????????</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://docman.cn/development/c-sharp/k-343822-14540/"&gt;http://docman.cn/development/c-sharp/k-343822-14540/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>[转]C#中Dispose和Close的区别！</title><link>http://blogs.msdn.com/brada/archive/2003/07/06/50127.aspx#9744548</link><pubDate>Sat, 13 Jun 2009 15:34:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9744548</guid><dc:creator>菩提树下的杨过</dc:creator><description>&lt;p&gt;原文地址:&lt;a rel="nofollow" target="_new" href="http://www.cnblogs.com/kevinwan/archive/2007/01/16/621869.html"&gt;http://www.cnblogs.com/kevinwan/archive/2007/01/16/621869.html&lt;/a&gt; 当我们开发C#代码的时候，经常碰到一个问题，有些clas...&lt;/p&gt;
</description></item></channel></rss>