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

Jason Hunter jhunter at collab.net
Fri Sep 15 19:54:11 PDT 2000


> getElements() is not ambiguous.  It doesn't imply that it recurses any
> more than getChildren() implies that it recurses.  Once you accept
> that an element can contain elements, it is not confusing (it only
> sounds self-referential, but it's not).

But element.getElement() -- the singular form -- does look way too
self-referential.

> getChildText(String name) is a convenience method anyway, but what
> would be the problem with renaming it getText(String name) ?  The
> presence of the parameter should clear up any ambiguity.

As much as I love the use of such a method, that's just awful.  You
don't change from parent text to child text retrieval based on a
parameter.

> Or not :-)

Yeah, I choose that one.  :-)

I like getChild() and getChildren() because it has a certain panache. 
Matches nicely with getParent().  Easy to tell them apart.  Nice and
short.  That naming makes me happy in a Zen sort of way.

-jh-



More information about the jdom-interest mailing list