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-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to