[jdom-interest] insertChild in Element

Tom Jenkins tjenkins at devis.com
Wed Aug 30 12:12:52 PDT 2000

Hello all,

> -----Original Message-----
> >All these things are easily done with the List returned by getChildren()
> >using standard Java APIs.  I think it's better to give people access to
> >the List for them to manipulate as they like than reproduce all the List
> >functionality in Element.
> >
> Lately I'm not so sure of that. Certainly, the getting the children
> and then operating on the list doesn't seem to be obvious. What if
> Element and Document implemented List instead of containing a List?
> Would this be more obvious? Would it be more closely reflect people's
> mental models of XML elements?

I don't think Element should implement List.  To my mental model, Element ->
List is not an "is-a" relation, but rather a "has-a".

The line:
	element.getChildren().add(newElement, 3);
makes perfect sense. But the alternative line:
	element.add(newElement, 3);
just doesn't feel right.

Tom Jenkins
Systems Analyst
Development Infostructure

More information about the jdom-interest mailing list