[jdom-interest] getChild() vs. getChildElements()

markd at lutris.com markd at lutris.com
Mon Jul 31 11:28:25 PDT 2000

Hi Jason

Jason Hunter <jhunter at collab.net> writes:
> > etc. It should very clearly be:
> > 
> > getChildElement()
> > getChildElements()
> -1

> The goal with getChildElement() is to reduce confusion for the new user
> (probably not necessary since we had zero jdom-interest questions about
> this from new users) at the cost of convenience for the regular user.

Personally, I found this very confusing.  The method doesn't do what the name
implies.   Not just from an XML/DOM perspective, but from a data structures
perspective (i.e. tree traversal).  The name getChildren() really implies
tree traversal.

> I do see your point, but I'm not willing to give up my convenience.  With
> getChildElement() the method I would use most would have to be named
> getChildElementTextTrim() and about the 10th time I call that method in
> a row (since you call these accessor methods a lot) I'm going to get as
> fed up with JDOM as I was with DOM.  Well, maybe not *that* annoyed, but
> close.:-)

I don't really consider saving typing a big convenience.  If I did, I wouldn't
be using Java :-) Convenience comes from providing higher levels of
expression.  The big convenience problem with the W3C DOM is that all of the
operations are at a fairly low-level, there isn't much in terms of high-level
access to data.  

Easy of understanding is also big `convenience' as well.  Being able to read
code and have an intuitive grasp of whats going (reads like of like english)
is a big plus.

Perhaps the thing to do is try an come up with new names that are both
shorter and more descriptive? (not that I have any great suggestions).


More information about the jdom-interest mailing list