Re: Problems Handling Errors Correctly



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
.



Relevant Pages

  • Re: Problems Handling Errors Correctly
    ... I'm a little confused because, according to Intellisense, HttpWebResponse has no Dispose method. ... So using Intellisense, you need to qualify the method as HttpWebResponse.IDisposable.Dispose or cast the instance to IDisposable. ... While FxCop is good in most cases of finding me IDisposable types I forget to dispose, it misses the ones (like HttpWebResponse) that are not constructed directly from my code but returned by other functions. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Repetitive XML comments -- whats the point?
    ... you will have description for this parameter in Intellisense. ... So while comment may seem long or redundant in source code, it is necessary for proper generation of IntelliSense and documentation. ... VSdocman - Commenter and generator of class documentation for C#, VB ..NET and ASP .NET code ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Repetitive XML comments -- whats the point?
    ... If you open compiled documentation for your project and your missing summaries and parameter descriptions it doesn't tell you that ... It simply tells you that the documentation wasn't finished. ... The same goes for intellisense, ... If you omit tag, you will have no method description in ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: XML Literals in VB9 - Whats wring with this?
    ... The documentation on XML intellisense focusses on documents with namespaces but I have tried a simple example here where I have written a schema with no targetNamespace and added that schema to my VB.NET project. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Repetitive XML comments -- whats the point?
    ... However, when they get translated into Intellisense or built documentation such as a CHM Help file, they aren't repetitive at all. ... Writing code and writing source code documentation require different skills. ...
    (microsoft.public.dotnet.languages.csharp)