Two kinds of interfaces

An interface is a point of interaction between two systems and they are used extensively within the Java world. While the mechanics of interfaces always are the same, the semantics may differ. There are (at least) two rather distinct types of uses for interfaces in Java.

One type of interface, which we might call separation interface, aims to separate different components. In this case, a component only exposes interfaces for its functionality but not the actual classes to make sure that clients aren’t too tightly coupled with the implementation. In this scenario, there is typically ever only a single implementation of the interface and both the interface and the implementation have the same author(s). Whenever you see a Interface/InterfaceImpl pair, you are most likely looking a this kind of interface use. This pattern is considered a best practice between components and systems, but rarely useful inside cohesive modules where classes naturally are more tightly coupled.

The other type of interface, let’s call it extension interface, is intended to represent an ability than an object can have. Here, multiple implementations of the interface exists and the client can choose the implementation that best suites his or her needs. A component often defines an interface on which it depends in order to allow implementations to be added at a later time. Often, the author of the interface is not even the same as the ones who create the implementations. This type of interfaces (together with regular inheritance) are the foundation of polymorphism. Iterable or Comparator are typical examples.

Quite possibly, there are other types of interfaces as well. Feel free to comment on the issue. :-)