[jdom-interest] getChildren() vs getElements()

Brett McLaughlin brett.mclaughlin at lutris.com
Fri Sep 15 13:33:56 PDT 2000


Will Glozer wrote:
> 
> I agree completely, getChild()/getChildren() is more
> understandable and clean imho.  It is nice to have
> verbose method names, but there is a point when it
> becomes far too verbose.

Except when they are wrong. getChild() implies a Child will get
returned, which does not mean an Element in XML. This has nothing to do
with verbosity, and I think it's funny that so many people think that a
child is equal to an Element in XML. It shows that we are only
propgating this incorrect assumption. But, that's certainly people's
right ;-)

And yes, getChildren() is not understandable. Even the people who go to
the Javadocs (and contrary to what some folks are saying, it's not so
common - most people don't even know how to build them, as earlier posts
brought to light) will see "List." Even a cursory reading of the XML
spec would lead you to think that List is not just Elements.

-Brett

> 
> Regards,
> Will
> 
> -----Original Message-----
> From: Jason Hunter [mailto:jhunter at collab.net]
> Sent: Friday, September 15, 2000 11:56 AM
> To: philip.nelson at omniresources.com
> Cc:
> Subject: Re: [jdom-interest] getChildren() vs getElements()
> 
> > Here I can agree with getChildElements() because we are
> > still consistent with the name getChild() which returns a
> > (strongly typed) Element wheras getChildren() returns a List
> > of Objects and only the docs can tell you what to expect.
> 
> The proposal isn't:
> 
> getChildElements()
> getChild()
> 
> The proposal is:
> 
> getChildElements()
> getChildElement()
> 
> The former wouldn't be consistent.  One problem with the latter is it's
> almost *too* consistent and hard to differentiate.  It's one reason I
> prefer getChild() / getChildren().  I also prefer it because it leaves
> the option to have getChildTextTrim() which I find really useful.  If we
> go with getChildElement() then it'd be getChildElementTextTrim() and
> that's just too many nouns to be understandable.
> 
> -jh-
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
> t.com
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list