[jdom-interest] no getChildTextNormalize() ?

philip.nelson at omniresources.com philip.nelson at omniresources.com
Thu Sep 27 14:46:03 PDT 2001


> exception.  A fair comparison is:
> 
>   return e.getChildTextTrim("c");
> 
>   versus
> 
>   Element e = getChild("c");
>   if (e != null) {
>     return e.getTextTrim();
>   }
>   else {
>     return "";
>   }

Really?!  I can hardly think of any project beyond a couple of weeks where I
haven't written a utility class that had a function that returned a default
or the value.  Even if JDOM had all the "convienience" getChild* functions,
I would still have a utility somewhere to return an empty string or the real
value because of JDBC among other uses.  So I then have

   Element e = getChild("c");
   if (e != null) 
     return Util.fixNull(e.getTextTrim());

or for a more specific use

return JDOMUtil.getElString(getChild("c"))

On the other hand, I have often regretted moving the interface of an
aggregated class upwards to the aggregate.  It clutters the aggregate, could
have issues with subclasses, and as was pointed out, makes the drop downs in
my ide harder to read.

less is more!



More information about the jdom-interest mailing list