I am just learning Java, so it is hard for me to access the possible alternatives, and the impact of such a design decision.
Java 8 adds the default methods feature to interfaces, which allows interfaces to have an implementation. This allows to extend the existing interfaces with new methods, without breaking the clients, evolving the interface over time in a backward-compatible way. However, given default implementation, such extensions are somewhat limited, and are likely to be implemented using existing interface methods of the interface or library methods. So my question is
- Why was this language feature introduced?
- What key new features does it support? (for instance Splititerators)
- What other alternatives were there to support those language features? For example, why not create a new interface SplitIterable that extends Iterable?
- What would be the impact of implementing those alternatives (poliferation of interfaces?)
- Should I provide a default implementation for a method in the first edition of interface when it is possible to implement it as a composition of other methods?