Enforcing Component Constraints
Cantor, Scott
cantor.2 at osu.edu
Thu Jan 26 14:49:01 EST 2017
> I was sharing some code with Daniel today and he mentioned that maybe the
> same approach could be used to make @NotNull and other constraints
> enforce the conditions at runtime. It's a combination of the new type
> annotations feature of Java 8 [1] and Spring AOP. Let me know if you're
> interested and I'll share some gists to clarify how it could work.
We're not on Java 8 yet, but more generally I guess it would depend what it was doing. The mention of IDE involvement made it sound more like the checking Eclipse does, and I've tested those enough to know they don't really work, they don't understand the code well enough.
I see what you mean about the AOP approach, obviously, since that would inject the constraints. The main problem there is just that often I consider the annotation a documentation tool. I think I've said in the past that I don't exactly get the point of documenting a parameter and then adding a check. If I'm checking, I'm apparently handling nulls. I know that's what we're doing, but the pattern predates me.
-- Scott
More information about the dev
mailing list