[jdom-interest] children as List

Rosen, Alex arosen at silverstream.com
Fri Sep 1 12:47:29 PDT 2000


> What is the definition of List if not an
> ordered set of items, the items  normally being called the children
> of the list? Element contains children in a particular order. Things
> that have ordered children are lists. Therefore Element is a list.
> QED.

The things in a List are not usually called its children, but its elements or contents.
(Talk about overloaded words - maybe "items" is better here.) So the system you propose
would mean that you'd ask for an Element's second item, not its second child, which
feels wrong.

A List *contains* things. You *could* say that an Element contains other Elements, but
it's much more natural to say that the Elements are children of the parent Element.
When I think of a List, I think of a long, rectangular box with other boxes inside;
when I think of Elements, I think of a box with other boxes drawn below it, as
children.

To me, the more relevent problem is that you'd get rid of the word "child" from the
code:

(1) element.getChildren().get(2)
(2) element.getChild(2)
(3) element.get(2)

In the last case, what you're getting from the element is not obvious. As someone
pointed out, since an Element is a container for Attributes too, this seems like a
deal-breaker for me. The first two choices are much clearer.

--Alex



More information about the jdom-interest mailing list