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

Chris Atkins atkicd at nm.usa.alcatel.com
Mon Jul 31 07:02:57 PDT 2000

I agree with getChildElement() and getChildElements().

It is clear to everyone exactly what you are getting.

Chris Atkins

> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of Brett McLaughlin
> Sent: Sunday, July 30, 2000 1:28 PM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] getChild() vs. getChildElements()
> All-
>   I'm very much against getChild() and getChildren(). Jason sort of
> glossed over this (he's a Java guy purely, though, so I understand ;-)
> ), but it is absolutely the wrong name for a method that only returns
> Elements. It is very clear from XML specs (XPath, XSLT, XPointer, pick
> any of them...) that a child is not just an Element. Additionally, we
> will continue to have lots of disillusioned DOM folks coming over, who
> also (correctly) realize that a child can be anything... element,
> entity, etc. So I'm very strongly against getChild(), getChildren(),
> etc. It should very clearly be:
> getChildElement()
> getChildElements()
> I know some folks think that shorter names are better, more 
> convenient,
> etc. This is just flat out wrong, I'm sorry to say, and not 
> ever a good
> reason to accept a name. We are coders - the next time 
> someone complains
> to me about having to type too much I'm going to throttle 
> them (I'm only
> partially kidding here). So I'm very strongly pushing a move to
> getChildElement() and getChildElements(), as that is what the methods
> do. I'm not going to put this in yet, but can almost guarantee it will
> be in before beta 5. As a good reiteration, here's the text of an old
> mail by Elliotte, which is right on target:
> >>>
> On a related note, I've been finishing up a medium-sized tutorial on 
> JDOM to be given next Monday evening at XMLDevCon, and I find that I 
> consistently misused getChildren() when what I really meant to do was 
> getMixedContent().  I'm beginning to get used to it now, but I 
> suspect this is a hurdle a lot of programmers are going to have to 
> cross. I propose renaming all the getChildren() methods 
> getChildElements() so there's no confusion. The various XML specs are 
> all quite clear that elements aren't the only kind of children. 
> Comments, processing instructions, and text nodes are children too. 
> Only attributes are not children. 
> >>>
> Thanks,
> Brett
> -- 
> 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
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com

More information about the jdom-interest mailing list