4 ms·
Relying on the IDE to know which exceptions can be thrown is nicer I think. No. If you can't remember what it throws, you can't remember the documentation. If
by swolchok 17y ago
Relying on the IDE to know which exceptions can be thrown is nicer I think.
No. If you can't remember what it throws, you can't remember the documentation. If you can't remember the documentation, you don't fully know how to use it properly. Go read the documentation; IDEs are a crutch.
EDIT: I'm completely serious. http://docs.python.org/library/ http://docs.python.org/library/ and help() are my best friends, in that order.
- nopassrecover 17y agoI think knowing every exception a method can throw and knowing the method are different things. I want to be able to write code, while I'm in the zone and thinking about the business problem, not have to jump and navigate a web site for every method call. And I didn't say you can't check the domentation from the IDE (through a nice context link) but I still think mouseover on a method that lists exceptions (as Visual Studio does) is the ideal solution as it gives me the information I need as I code. NB: VS exception info is comment documentation based, I have no idea why the compiler doesn't generate this information as much as possible becuase then you are getting some of the advantage of checked exceptions without the cost. As a counterpoint to knowing the documentation, consider the System.Reflection.MethodBase.Invoke method in .NET which I have in front of me, are you going to remember all these exceptions: // Exceptions: // System.Reflection.TargetException: // The obj parameter is null and the method is not static. -or- The method // is not declared or inherited by the class of obj. -or- A static constructor // is invoked, and obj is neither null nor an instance of the class that declared // the constructor. // // System.ArgumentException: // The elements of the parameters array do not match the signature of the method // or constructor reflected by this instance. // // System.Reflection.TargetInvocationException: // The invoked method or constructor throws an exception. // // System.Reflection.TargetParameterCountException: // The parameters array does not have the correct number of arguments. // // System.MethodAccessException: // The caller does not have permission to execute the constructor. // // System.InvalidOperationException: // The type that declares the method is an open generic type. That is, the System.Type.ContainsGenericParameters // property returns true for the declaring type.
- swolchok 17y agoI didn't say you have to know the documentation, and I'll admit I'm behind on how much of it IDEs show you. In my recollection, you generally get a list of language-level constructs and that's it. For example, the names of those exceptions are not as useful as the text you've shown there. If VS does that for exceptions, great! Contrast it with the 2003/2005 IntelliSense feature, where you just get method prototypes.
- nopassrecover 17y agoI misinterpreted "No. If you can't remember what it throws, you can't remember the documentation" as know the documentation but I can see your point now. Yeah and you just get a list of possible exceptions rather than a description of each which is a fair point to make too. Maybe it's configurable though.