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

Elliotte Rusty Harold elharo at metalab.unc.edu
Sun May 5 07:58:42 PDT 2002


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


public int *getAttributeType*()
public Attribute <cid:part1.03050708.09010603 at metalab.unc.edu> 
*setAttributeType*(int type)

There's no need to repeat the classname 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.

-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|           The XML Bible, 2nd Edition (IDG Books, 2001)             |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:   http://www.cafeaulait.org/     | 
|  Read Cafe con Leche for XML News:  http://www.cafeconleche.org/   |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list