On Thursday, Aug 14, 2003, at 11:36 Europe/London, Jason Dillon wrote:
I do not agree with the Exceptions section listed in the wiki. I think that a NPE can be thrown where appropriate. For argument methods which must not be null a NPE is not appropriate. I think we should change the text to make it clear that if you must throw an NPE, then it is okay, but that you need to have a reason todo so and that it must have a description.
I put that there to wean people away from the NPE re: discussions on this topic.
If you can give me a clear example of when throwing an NPE is desirable, please do so. But for every example you'll give, I'll ask why it couldn't be either an IllegalArgumentException (if it is to do with arguments), or if not a generic RuntimeException (with suitable messages).
That way, NPEs can be reserved for unwanted program bugs, and fixed and stamped on with all ferociousness.
Alex.
