On Mon, Jun 16, 2008 at 10:26 PM, Georg Ragaller <[EMAIL PROTECTED]> wrote:

> Should we really do that? So we won't get an NPE if this NPE comes from
> an implementation error in the constraint***, but a valid result (false
> in this case).
>
> I think we should add the null check to the expression like I did it:
>
> OLD:    value.trim().length() > 0;
> NEW:    (null != value) && (value.trim().length() > 0);
>
> which is also 'simplistic' and the Constraint#isValid javadoc should
> state that 'value' can be null.

There are of course good argument for both cases.

I think Rickard is trying to avoid that the "value" argument need to
be checked everywhere in the constrain implementations.

Perhaps a middle-ground is achievable by letting the Constraint
declare if it accepts (or not) null arguments, and if it does not,
then the caller will fail before making the call. I think in that set
up, we get good stuff from both worlds - No need to check for null
arguments, and get NPE in constraint bugs.


Cheers
Niclas

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to