Re: Problems Handling Errors Correctly
- From: Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Sat, 15 Sep 2007 20:58:09 -0700
Jonathan Wood wrote:
Well, okay, I guess you're talking about near the bottom of that page? I'm a little confused because, according to Intellisense, HttpWebResponse has no Dispose method. Yet, near the bottom of the members page, it does list System.IDisposable.Dispose.
Yes. It's an explicit implementation, which means you can only access the method via the interface IDisposable. So using Intellisense, you need to qualify the method as HttpWebResponse.IDisposable.Dispose or cast the instance to IDisposable.
[...]
I was thinking more along the lines of Intellisense seeming to indicate that HttpWebResponse has no Dispose method, and that's why I said looking for the Dispose method may not be a reliable method of determining if a class implements IDisposable. Am I off track here?
While I find it very useful, IMHO Intellisense is not a substitute for reading the documentation. :)
Nevertheless, Intellisense usually can lead you to the correct information about what a class implements, if you know the magic incantation to get it to show you that. As with the documentation, it's a matter of gaining experience with it.
Knowing how to use the documentation is half the battle. To some extent, that requires simply practicing reading the docs.
Well, I started developing software in 1987 and I've pretty much used MS stuff so I'm thinking I have some idea how to use the help.
Um. Okay. That's why you knew where to find out whether a class implements IDisposable or not? :)
Seriously though, your past experience is not necessarily going to help you with things you are unfamiliar with. I've been programming a fair bit longer than you have, but I'm still practically a newbie when it comes to .NET and C#. Practically every day I run across something that my past experience hasn't helped me at all with.
So, no matter how experienced you are, it is often helpful to keep in mind that there are always new things to learn. It's human nature to blame the docs or the framework or whatever, but usually if you can just try to put yourself in the same mindset as the human being who designed the docs or the framework or whatever, things that seem arbitrary and a "pain in the ass" turn out to just be a part of an unfamiliar-but-consistent design.
In the case of interface documentation, every class's "Members" page includes at the bottom a section that describes the interfaces implemented by the class (or at least the explicit ones...you have to look under the regular methods sections also to see if IDisposable() was implemented implicitly; and no I don't know if there's a general rule for which classes implement it explicitly and which implement it implicitly).
The classes themselves might not be completely consistent, but there is a single doc page that will tell you everything you need to know, and the documentation itself is consistent. It's very predictable how to find out the information, once you become accustomed to looking for it. MSDN definitely is not "hiding" this information from you.
[...]Yeah, I suppose you're right. Although I can't imagine a well-written class that stays "open" after calling Dispose().
It's not really so much the question of a class staying open. It's whether calling Close() does something different than Dispose().
Well, I put "open" in quotes. I just meant whatever is needed to clean up.
Well, then you aren't necessarily talking about a class with a Close() method then.
Pete
.
- Follow-Ups:
- Re: Problems Handling Errors Correctly
- From: Jonathan Wood
- Re: Problems Handling Errors Correctly
- From: Doug Semler
- Re: Problems Handling Errors Correctly
- References:
- Problems Handling Errors Correctly
- From: Jonathan Wood
- Re: Problems Handling Errors Correctly
- From: Peter Duniho
- Re: Problems Handling Errors Correctly
- From: Jonathan Wood
- Re: Problems Handling Errors Correctly
- From: Peter Duniho
- Re: Problems Handling Errors Correctly
- From: Jonathan Wood
- Re: Problems Handling Errors Correctly
- From: Peter Duniho
- Re: Problems Handling Errors Correctly
- From: Jonathan Wood
- Problems Handling Errors Correctly
- Prev by Date: Scale a vector
- Next by Date: Re: Scale a vector
- Previous by thread: Re: Problems Handling Errors Correctly
- Next by thread: Re: Problems Handling Errors Correctly
- Index(es):
Relevant Pages
|