Defender Extension Methods -- Resolution and Invoccation

Neal Gafter neal at gafter.com
Wed Aug 4 17:08:10 PDT 2010


On Wed, Aug 4, 2010 at 4:18 PM, Lawrence Kesteloot <lk at teamten.com> wrote:

> On Wed, Aug 4, 2010 at 3:52 PM, Neal Gafter <neal at gafter.com> wrote:
> > It seems you've technically observed the word of "keep interfaces
> code-free"
> > without obeying the spirit of it.  There is little point of putting the
> > programmer through the pain of the separation in the current
> specification
> > if the benefits of the separation don't accrue.
>
> What are you advocating? Putting the code right in the interface? What
> if the method gets too big, how do you split it up?


Any way you like.  You even have the possibility (an option, not a
requirement) of a trivial implementation that defers to a static method in
some other class.  We could allow a private nested class inside the
interface (not legal today in the language, but legal in the VM) to assist
with the implementation.


> Do you advocate
> private methods in interfaces to solve that? Private static fields to
> store things like Comparators or Collators you might use? Seems like a
> mess to me. I should be able to read an interface and see a contract,
> not hundreds of lines of implementation and private garbage.
>

That's true of classes too.  If you want to read the contract, you should be
looking at the javadoc, not the code.


More information about the lambda-dev mailing list