[jdom-interest] Element Reference from Attribute

Patrick Dowler Patrick.Dowler at nrc.ca
Tue Nov 28 10:25:01 PST 2000

On Tue, 28 Nov 2000, Louis Tribble wrote:
> James Strachan wrote:
> > However in most code everywhere (except in your own custom builder) you
> > actually refer to the common base class most of the time. Its only when you
> > want to do 'special things' that you cast. So I now favour the common base
> > class being Element / Atttribute. Due to the polymorphic Node interface
> > proposal, which only the doubly linked implementation would implement, my
> > favoured naming scheme now is Attribute -> AttributeNode. The postfix of
> > Node is an extra visual clue that the object is-a Node
> _Everything_ here is a node, if not a Node. I don't find that using 
> "Node" in the names is meaningful. Better to use "Double" or "Bi" or 
> "2" or "Extended" on the one hand, or "Base" or "Single" on the other 
> hand.
> If the decision is taken to go to two tiers, I believe the doubly
> linked one should be the default and have the "default" names:
> that will allow presenters and casual users to deal with only one 
> hierarchy. The singly linked hierarchy can be left for the
> advanced (optimization) chapter...

The problem is that the methods in the base class have to return
base class types, namely:

      public BaseElement getChild(String name) { ... }

This means that even in the derived class, you have to refer to
BaseElement most(?) of the time (and cast to Element when
needed). With "Node" you generally refer to Element  and ElementNode
when the extra features are used. I'd prefer a name of the form
???Element to mean an "enhanced kind of element"... it is
more in keeping with standard to prepend a qualifier. (Set vs. SortedSet,
Map vs. HashMap/TreeMap, for example). 

The preference is clearly that method signatures that are common use
Element. That suggest that Element is the base type. I suggest we use
something cool and meaningless like FuElement and then put all the
extensions (like XPath) into the org.jdom.fu package :-)


Patrick Dowler
Canadian Astronomy Data Centre

More information about the jdom-interest mailing list