[jdom-interest] new element methods?
Elliotte Rusty Harold
elharo at metalab.unc.edu
Tue Jul 15 12:35:11 PDT 2003
At 10:07 AM -0400 7/15/03, William Krick wrote:
>I was wondering if it might be useful to add some methods to Element...
>
> getInt(java.lang.String name)
>
> getFloat(java.lang.String name)
>
> getBoolean(java.lang.String name)
>
> getString(java.lang.String name)
>
Such methods did make it into one of the betas a couple of years ago.
They were eventually removed on the grounds that there were just too
many methods in the class. While every such method seems plausible
and useful when considered in isolation, adding every convenience
methods requested rapidly grows the class to the point of
illegibility.
API size has a huge cost to ease of use, and there's a point at which
it begins to grow exponentially. The first five or six methods are
effectively free. The next five or six are worth the cost. Beyond
that the cost starts skyrocketing, and it gets much worse with each
batch of methods you add. 40 public members is really the effective
outer limit of a good class. Beyond that it's time to start asking if
you can refactor into more smaller classes. Element is already quite
large. It really can't handle the weight of a whole new batch of
convenience methods.
--
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