[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On Tue, 16 Oct 2018 16:55:02 -0700, Eric Barnhill wrote:

The Fraction class is IMO looking good (in better shape than Complexwasin) and is already quite close to fulfilling the standards for aVALJO.Equals() and CompareTo() are well designed and consistent. I see two missing steps. The easy one is a parse() method which mirrors thetoString() method. The harder one is the wide range of publicconstructors.To be a VALJO all constructors must be private and accessed withstaticfactory methods. If these factory methods themselves can beoverloaded, Ithink a decent schema emerges: current constructor -> proposed factory method -------------------------------------------------------- public Fraction(double value) -> public fromDouble(double value)public Fraction(double value, double epsilon, int maxIterations) ->publicfromDouble(double value, double epsilon, int maxIterations)public Fraction(double value,int maxDenominator) -> publicfromDouble(double value,int maxDenominator) public Fraction(int value) -> public fromInt(int value)public Fraction(int num, int denom) -> public fromInt(int num, intdenom)

Why not call them all "of(...)" ? Gilles

so this is what I propose to go with.If disambiguation in the double cases is still a problem, the secondandthird of the double constructors could be fromDoubleEpsMaxInt and fromDoubleMaxDenom . EricOn Thu, Oct 11, 2018 at 7:00 AM Gilles <gilles@xxxxxxxxxxxxxxxxxxxxx>wrote:On Wed, 10 Oct 2018 16:18:50 -0700, Eric Barnhill wrote: > I am interested in moving forward on making the Fraction classes > VALJOs > [NUMBERS-75]. >> Just a preliminary question for now, are we otherwise happy withthe> Fraction class in the context of commons-numbers? Or should I look > around> for any odd behaviors leftover from commons-math (Complex had alot> of > those) that might also be improved? AFAIK, there was no in-depth review as was done for "Complex". So it would indeed be quite useful to check what the Javadoc states, whether it seems acceptable (wrt what other libraries do), and whether the unit tests validate everything. Side note: Unless I'm overlooking something, completing this task will result in getting rid of all the formatting and "Locale"-related classes (as for "Complex"). Best, Gilles > > Eric

--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@xxxxxxxxxxxxxxxxxx For additional commands, e-mail: dev-help@xxxxxxxxxxxxxxxxxx

- Prev by Date:
**Re: [ALL] Spaces in paths - change Jenkins jobs to use spaces?** - Next by Date:
**[GitHub] darkma773r closed pull request #14: GEOMETRY-14: Initial AffineTransform3D class** - Previous by thread:
**Re: [numbers] Making fractions VALJOs** - Next by thread:
**Re: [numbers] Making fractions VALJOs** - Index(es):