[jdom-interest] A utility Element subclass and a request for API extension

Les Hill leh at galaxynine.com
Fri Mar 22 13:11:23 PST 2002


patrick.dowler at nrc.ca wrote:

Patrick, you are 95% of the way there!  You just need a nudge...

>Generally, one can confine these conversions to a few classes and then a
>suitable overloaded method of the form
>
>         private String str( double d ) { ... }
>
>makes the code look ok.

This works for a while, then you add one or two or ten classes and decide
that cutting and pasting the same set of static methods to every new class
is a wee-bit tedious and error-producing.  Of course, you could try to
factor all these methods up to a base class (or classes) and that might work
for while as well.

Eventually, you will simply write one class that handles all the conversions
for you.  At that point you will end up asking yourself: why do I have to
create this utility class to handle native types?

You bring up another point:

>return NumberFormat.getInstance( locale ).format( d );
>
>you can do it in one place AND you get to decide/ which you need and change
it if required.

You always had (and would continue to have) this capability, the proposed
changes are not taking anything away.

Les Hill
leh at galaxynine.com





More information about the jdom-interest mailing list