News for hackers. Stuff that matters.
Re:Go's power is in emergent behavior by e12e on Sunday April 27, 2014 @01:49AM (#7654124)
I suppose it might be "bad form", but couldn't you, if you had:

  public interface FooBar
  {
     int foo();
     int bar();
  }
  public Afob implements FooBar {...}
refactor FooBar to simply:

    public interface Foo { int foo() }
    public interface Bar { int bar() }
    public interface FooBar extends Foo, Bar {}
And keep FooBar the way it was, but now cast it to a Foo (or Bar) when you don't want a FooBar?
Re:Go's power is in emergent behavior by pron on Sunday April 27, 2014 @06:32AM (#7654598)
The problem is with

    interface FooBar extends Foo, Bar {}
FooBar can be defined in a library that you can't change. The solution in Java 8 would be using default methods:

    interface Foo extends FooBar {
        default int bar() { throw new UnsupportedOperationException(); }
    }
And then you can even do the other trick mentioned in the article even more easily:

    Foo f = () -> 3;
And f now satisfies FooBar, by throwing an exception when bar is called, and returning 3 when foo is called.

But, assuming method

    void doSomething(FooBar x) { ... }
you can't call it like this:

    doSomething(() -> 3);
What you can do is call it like this:

    doSomething((Foo)() -> 3);