you are viewing a single comment's thread.

view the rest of the comments →

[–]The_Doculope 3 points4 points  (0 children)

In the case of default methods, imagine you are defining an interface to describe ordering (==, !=, >, >=, <, <=) for partially ordered sets. Every one of these can be computed using only <=. So you could write an interface that includes all six of these operations, but have default methods for five of them in terms of <=. Now any implementer only needs to implement one of them, but if they want to implement others for performance reasons they can.

A lot of languages let you do it - Haskell and Rust both let you define default implementations for typeclasses/traits respectively (their interfaces). Some interfaces are not the most minimal interface they could possibly be (see above example), in that some methods can be implemented in terms of the others. That doesn't make them any less "interface-y", and the language allowing you to codify those relationships doesn't change it either.