commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juozas Baliuka" <bali...@centras.lt>
Subject Re: [Lang] Validate! [was: Assertions?]
Date Tue, 22 Oct 2002 17:25:24 GMT
Hi,

agree "Validation" is a better name for this stuff and it can throw "custom"
exeptions.

public class NotNullableArgValidationFailed extends IllegalArgumentExeption
.....
user can catch "IAE" but will be more clear. Somebody can think argument is
"bad" for validation  function, not for caller in some third party code.




Validation makes a lot more sense to me, also. [Boy, my sister in law came
to
visit for the weekend, and I'm behind by over 100 messages]

In particular, although a number of the methods are trivial, some are not.
No
nulls in an Object array, for example, or null list elements. As long as all
the elements would be traversed anyway, it's not that much overhead, and
helps document the expectations of the rest of the code.

OTOH, I do have to ask if transforming a NPE to an IAE is really a win? Fail
fast is nice, though. And for non-null checks, eg isNotEmpty() or
isNotZero(), you may transform a silent error to an IAE.

$0.02.


On Tuesday 22 October 2002 03:00 am, Ola Berg wrote:
> From: "Paul Cantrell" <cantrell@pobox.com>
>
> > That's why it would probably be best to choose a method name which made
> > it clear that the method is for argument validation, not null checking
> > in general.
>
> Validate it is then!
>
> > I actually use IllegalStateException rather often, and
> > UnsupportedOperation on occasion.
>
> Of course we use a lot of different exceptions. But for validating risky
> (aka user provided) arguments (which is what we have in mind), IAE is very
> appropriate.
>
> From: "Stephen Colebourne" <scolebourne@btopenworld.com>
>
> > I have a class like this at both work (called Assert) and in the Joda
> > project (called Validate).
>
> Me to (but they are called Assert). Why can't you, Stephen, check some of
> this in (into lang sandbox?) so that we can have a go at it?
>
> /O


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



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


Mime
View raw message