[jdom-interest] More changes

Brett McLaughlin brett.mclaughlin at lutris.com
Wed Jul 19 10:19:59 PDT 2000

Elliotte Rusty Harold wrote:
> At 10:35 AM -0500 7/19/00, Brett McLaughlin wrote:
> >* What do people think about removing the convenience methods (like
> >getIntContent()) on Element.java? Mark Diekhans pointed out that getting
> >a default value from an attribute is quite different from getting one
> >from an Element - typically, it means the Element is optional, or not
> >there, but we also return the default if the /format/ is incorrect.  For
> >example:
> >
> ><port>yl7</port>
> >
> >getPort(80);
> >
> >This currently returns 80, and should really result in an error - it
> >masks problems in the underlying XML, which is generally a bad thing, I
> >think. It is very hard to track this down, and different programs using
> >different defaults can really obfuscate the document. So I'm actually
> >for removing all the getXXXContent methods (but only on Element.java,
> >not Attribute.java, where they make more sense).
> >
> I agree, but for different reasons:
> I've come to believe these methods are unimportant syntactic sugar,
> that add complexity to the API while providing no real benefit to
> most programmers. The smaller JDOM is, the  simpler and easier it is
> to learn and document. 80+ methods in a class simply looks too
> intimidating even if you can ignore most of them most of the time.
> I'd simply rather have fewer methods in the class.
> I do see your point about the problem with returning the default
> where the format is incorrect. However, I'm not sure why this
> reasoning applies to Element and not to Attribute. After all,
> wouldn't we have exactly the same set of problems with <connection
> port="y80"/>?  Perhaps we should remove the overloaded methods that
> provide a default value from Attribute?  Or perhaps they should only
> return the default value if the attribute is missing but throw a
> NumberFormatException if the format is in error.

OK. So all getXXXContent methods go, on Element.java.

On Attribute.java, are people using the method with the default value?
If not, let's remove them too....

removing methods... I like this ;-)


> +-----------------------+------------------------+-------------------+
> | Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
> +-----------------------+------------------------+-------------------+
> |                  The XML Bible (IDG Books, 1999)                   |
> |              http://metalab.unc.edu/xml/books/bible/               |
> |   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
> +----------------------------------+---------------------------------+
> |  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
> |  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
> +----------------------------------+---------------------------------+
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 

More information about the jdom-interest mailing list