commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Commons Wiki] Update of "Sanity Check of APIs, etc." by MattBenson
Date Sat, 21 Jan 2012 02:53:37 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Commons Wiki" for change notification.

The "Sanity Check of APIs, etc." page has been changed by MattBenson:


  Address open questions:
   * '''''there are several marker interfaces, but maybe some annotations would make more
+    This and the next question seem to dovetail since "several" marker interfaces == Functor/NullaryFunctor/UnaryFunctor/BinaryFunctor.
 See my comments on that question for why I think it is a good idea to continue strongly distinguishing
these n-ary functor "profiles."  These marker interfaces were added because I thought it might
occasionally be handy to be able to broadly classify functors, n-ary functors.  I can't think
of a more usable way to accomplish the same goals using annotations.
   * '''''couldn't Function, UnaryFunction and BinaryFunction be unified with a single interface
using a vararg parameter?'''''
+    (Same question would apply to -Predicate and -Procedure in addition to -Function) Using
a vararg parameter would preclude the binary (and hypothetical ternary, etc.) functors from
supporting different strongly typed arguments.  I think it would be a step backward.  MJB
   * '''''EachElement should be able to work on any Iterable. Also I'm not sure to understand
why its constructor is public.'''''
   * '''''Shouldn't Generator implement Iterable?'''''
   * '''''why are equals, hashCode and toString defined in the Functor interface?'''''
+    I don't feel strongly about this.  The original author/s of [functor] presumably used
this as a natural place to put their javadoc comments urging that functor implementations
properly implement these methods.  Feel free to POLL or VOTE on the dev list.
   * '''''why Predicate isn't an extension of Function<Boolean> ?'''''
+    I personally support the original authors' decision to let each functor type have a simple
and semantically straightforward API.  [functor] already has adapters to handle this transformation;
forcing Predicate to be Function<Boolean> would require either a less semantically pleasing
API, or a more complicated implementation task.
   * '''''why Procedure isn't an extension of Function<Void> ?'''''
+    See answer to previous question.
   * '''''Why are constants available through both a static field AND a static method? For
example Identity.INSTANCE and Identify.instance(), or Constant.TRUE and Constant.truePredicate()
+    The static method is the option to choose for strong typing.  I don't feel strongly about
retaining the static fields which of course predated the generics work.  If you want, JFDI.
   * '''''The Javadoc for Limit states "A predicate that returns true the first n times it
is invoked.", but what happens after? Is it the opposite of Offset?'''''
@@ -25, +31 @@

   * '''''Limit and Offset could probably use an AtomicInteger instead of a synchronized block'''''
   * '''''the site has no example easily accessible, the reader is invited to browse the JUnit
tests. That's not really user friendly.'''''
   * '''''I see IllegalArgumentExceptions thrown for null values, shouldn't this be changed
to throw NullPointerExceptions ?'''''
+    Agreed.
   * '''''@inheritDoc tags should be removed if no additional description is provided in the
subclasses. This tag is only useful for extending the description from the method of the super

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message