commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <>
Subject Re: [math] cleaning code
Date Sun, 27 Mar 2011 21:21:51 GMT

> In class MathUtils, method round(double x, int scale, int
> roundingMethod) we catch RuntimeException to wrap it into
> MathRuntimeException. I think we should not and should simply let the
> RuntimeException go up. What do you think ?


> SerializablePair extends Pair which is not serializable and does not
> have an accessible void constructor. Should we add such a constructor
> (perhaps setting the two fields to null), should we have
> SerializablePair not extend Pair or are we sure this does work correctly
> and we should add a findbugs excude filter ?

Indeed, it seems that this does not work as I expected. Adding a default
constructor does not seem to help either.
I do not favour creating classes when it means reinventing the wheel
especially when the functionality is not CM's core business. CM's "Pair"
class is only used in "sortInPlace" which is never used within CM: It was
intended as a utility so that users can easily pass sorted arrays to CM
methods that require them (e.g. interpolators).
The "SerializablePair" was a quick-and-dirty trick to allow serialization of
"MathRuntimeException" objects. It works for that purpose but it now looks
like we are led to enhance "SerializablePair" so that it behaves as its name
implies. However that's yet another piece of code that should not be
supported by CM.
It's a pity that CM cannot even rely on other Commons code (such as "Lang",
which contains a "Pair" class).
If this is still not an option (!), I'd rather remove the "SerializablePair"
class and change the code in "MathRuntimeException".


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message