Is this code convertible to a lambda style?

Brian Goetz brian.goetz at oracle.com
Sat Dec 28 08:26:36 PST 2013


> Some lambda functions will have explicit parameters and others not. I
> don't like the final result visually. I think it's better to stick to
> one style when it is possible.

I would correct this to "when it is beneficial".  Consistency is not the 
ultimate goal, or an end unto itself.  Readability is far more 
important.  (Yes, gratuitous inconsistency inhibits readability, but so 
does gratuitous consistency.)

Unfortunately improving readability is not simply a matter of maximizing 
consistency.  Sometimes adding explicit parameter types makes it more 
readable; sometimes adding explicit types makes it less readable.  Same 
is true with replacing lambdas with method refs.

(Overall my experience is that static/unbound method refs are almost 
always more readable than their equivalent lambdas, but bound methods 
refs sometimes are and sometimes are not, and call for judgment.)


More information about the lambda-dev mailing list