Hello all,
Currently I am using Qi4j in my MSc thesis implementation, and a
situation arose, where I think it would be handy to add contraints to
something else than method parameters, for example method return
value. And as far as I understand, currently constraints can be
currently added only to method parameters.
Reason: Because adding constraints to method input is similar in style
of 'programming by contract' (that's a TM i think), it would be
consistent and desirable to add constraints to method output too.
Current workaround:
Concerns. For example, suppose you want to make sure, that the return
value of some method never returns null. You create a generic concern,
with needed @AppliesTo(...) filter, which invokes a method, and then
checks whether result is null or not, if applicable (obviously for
non-void methods).
This is a little clumsy though, since for each composite declaration
one must add the @Concerns({...}) annotation. So it would be very much
easier and more elegant to do it with constraints. I don't think you
would even need to change Constraint<ANNOTATION, TYPE> interface.
Also, IMO, checking the result value against static conditions falls
more on a responsibility area of constraints rather than concerns.
What do you think about this?
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev