commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ori ziv <zivo...@gmail.com>
Subject Re: [math] basic utilities for probability - isProbability(double) and isSampleSpace(double[])
Date Tue, 17 Jul 2012 15:13:17 GMT
Don't you the following as disadvantages of the Preconditions way ?
* It forces you to write "p >= 0 && p <= 1" anytime. even it is a
trivial condition, you might mistake and get the inequality sign in
the wrong way, or forget the equals sign.
* You are depended on guava, and I guess you can't do that on
functions inside the CM.

On Tue, Jul 17, 2012 at 4:15 PM, Gilles Sadowski
<gilles@harfang.homelinux.org> wrote:
> On Mon, Jul 16, 2012 at 05:16:30PM -0700, Ted Dunning wrote:
>> I ask about trivial routines like isProbability().  Why is that any better
>> than just saying
>>
>>        Preconditions.checkArgument(p >= 0 && p <= 1);
>>
>> or checkState if it isn't an argument?
>>
>> I would argue that checkArgument is more transparent.
>
> I'd say that it's not better or worse; it's different. :-)
>
> If the purpose is to throw a basic exception, I agree that Preconditions is
> an elegant way, and is more concise (in vertical space) than an "if" block.
>
> However, we need to throw a specific exception and create a customized
> and localizable error message. This already exists in CM and should be
> modified. I don't think that it's worth it just to look like
> "Preconditions".
> In some place the effect and the look are already quite similar: E.g. line 55
> of src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegrator
>
> ---
> MathArrays.checkOrder(points, MathArrays.OrderDirection.INCREASING, true, true);
> ---
>
>
> Regards,
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message