[jdom-interest] Re: NoSuch*Exception

Thomas M. Sasala tsasala at hifusion.com
Wed Jun 28 04:54:55 PDT 2000


Sirtaj Singh Kang wrote:

	If null is returned and it is not checked for,
then you will get a null pointer exception.  There's your
error ;)

	-Tom

> 
> Hi,
> 
> I personally prefer throwing an exception, because it reduces the chances
> of bugs. Most programmers have the tendency of writing "best case" code
> that assumes that nothing will go wrong and you can always write the error
> handling code later.
> 
> The result? The code checking for a missing element rarely gets written,
> and your bug only shows up on the odd chance of a null exception.
> 
> The chance of an exception being thrown forces programmers to deal with
> the situation up front. I'm sure a lot of you consider yourselves to be
> above errors like these, but everyone makes mistakes, and you don't want
> them showing themselves in the field. This is what exceptions were
> designed for in the first place.
> 
> I'm also of the opinion that the bit of somewhat ugly code you have to
> write to catch an exception when checking for an optional element is made
> up by not having to check for null on every call.
> 
> My 2c...
> 
> -Taj.
> 
> PS. Validation of the document won't save you from misspelling the element
> name in your code.
> 
> Sirtaj S. Kang       taj at kde.org         ssk at physics.unimelb.edu.au
> Univ of Melbourne       The "gui" in "Penguin" is pronounced "K-D-E"
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list