[jdom-interest] [Vote] NoSuchChildException

Dave Hurrell dave at greatchiro.com
Thu Jul 13 01:53:31 PDT 2000

-1 on returning a null

The original question that led to this poll was:

> Element's methods getAttribute() and getChild() now throws
> NoSuchElementException and NoSuchAttributeException.
> Do you think this is better than returning null in such cases?
> Since it often happens that you don't know whether child or attribute
> exists and it is very awkward to handle those Exceptions. -Simon

The question is flawed; neither of the alternatives are good
design   No exceptions should be thrown and "the value" or
"a default value" should always be returned.  There should
be a separate method to query Element or Attribute objects
for whether the data exists.  Existence and content should be
mutually independent.  --GreatOne

More information about the jdom-interest mailing list