commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: [Math] MathUtils.checkOrder
Date Thu, 22 Sep 2011 00:41:44 GMT
On 9/21/11 4:33 PM, Greg Sterijevski wrote:
> Gilles,
>
> I do not understand why a non-monotone collection should throw a
> IllegalArgumentException...? There is nothing wrong with the argument, it
> just is not in corrected order. Wouldn't it be better to return a false?

I think as you guys are pretty much agreeing, we are talking about
two different methods here.  The "check*" methods are really there
to help with parameter checking, so it makes sense for them to throw
when what they are "checking" fails.  What you want should probably
be called "isMonotone."  That would also be useful and could be
called by the check method.

As a side note, I notice now that "NonMonotonousSequenceException"
is misnamed.  It should be "NonMonotoneSequenceException."  I think
it would be good to fix that for 3.0.

Phil

>
> We have:
>
>             if (!ok && abort) {
>                 throw new NonMonotonousSequenceException(val[i], previous,
> i, dir, strict);
>             }
>
> Why throw this? Why not return false and let the code calling this method
> decide if it wants to throw an exception?
>
> On Wed, Sep 21, 2011 at 5:56 PM, Gilles Sadowski <
> gilles@harfang.homelinux.org> wrote:
>
>> On Wed, Sep 21, 2011 at 05:17:59PM -0500, Greg Sterijevski wrote:
>>> Meant to say add, not replace. My apologies. -Greg
>> I like this better! ;-)
>> [But, still, please check the intended meaning of the first argument of
>> (sub-classes of) "MathIllegalArgumentException".]
>>
>> 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