nonNull and similar methods [was Re: First round of java.util.Objects for code review (bug 6797535)]
kevinb at google.com
Fri Oct 23 12:33:10 PDT 2009
On Wed, Oct 14, 2009 at 3:38 AM, Stephen Colebourne <scolebourne at joda.org>wrote:
While I agree that the nonNull methods below are useful and should be in the
> JDK, I question whether they should be on j.u.Objects.
> I believe that there is a whole category of methods to pre-validate the
> arguments of a method, such as Commons Lang Validate, or Google Prevalidate.
I'm in complete agreement, of course. In Google, checkNotNull() is
certainly the most popular of our Preconditions methods, but checkArgument()
is fully half as popular, and checkState() half in turn (meaning it's still
used thousands upon thousands of times). We also have similar methods to
throw IndexOutOfBoundsExceptions when appropriate, which are not needed
nearly as frequently, but are a real relief to use when you do need them
(many JDK methods could make use of them, especially since Martin has just
finished optimizing the heck out of them for our next RC (1.0-rc4)).
checkArgument() and checkState() don't let developers do anything they can't
already do with if/throw, but I very strongly believe we have significantly
more of our codebase doing proper precondition checking because of this
small amount of paving we applied to that path.
Just some more input to consider.
Kevin Bourrillion @ Google
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the core-libs-dev