[jdom-interest] Redundance in getAttributeType() and setAttributeType()

Elliotte Rusty Harold elharo at metalab.unc.edu
Sun May 4 11:42:19 PDT 2003


Pusing another issue from last year that was never decided back into the queue:

The following two methods in Attribute strike me as redundantly named:


public int *getAttributeType*()
public Attribute *setAttributeType*(int type)

There's no need to repeat the class name here. We don't use 
setElementText() and getElementText() in Element or setTextValue() 
and getTextValue() in Text. In Attribute itself we say setName() and 
getName(), not setAttributeName() and getAttributeName().

There are cases where we do use the type name, but these are when the 
calling object is not the type we set or get; e.g. 
getAttributeValue() in Element. In that case, merely using getValue() 
would be misleading because it would imply the value of the element 
is being gotten instead of the value of the attribute. However, in 
the Attribute class there's no such confusion. The natural type to be 
setting or getting is the attribute type.

Last year, Laurent point out that if we ever add a common Node 
superclass, then that might have a separate getType method. However, 
that seems unlikely to happen, and even if it does that method should 
probably be called getNodeType.
-- 
Elliotte Rusty Harold
elharo at metalab.unc.edu
Processing XML with Java (Addison-Wesley, 2002)
   http://www.cafeconleche.org/books/xmljava
   http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA



More information about the jdom-interest mailing list