4.3.1 Class interface

A class traditionally provides both an implementation and an interface. It is the interface that enables a class to be used as a type. Interfaces wedded to a particular class are known as class interfaces, and are the sole means of accessing objects in languages with no concept of freestanding interfaces. Many modern object-oriented languages, such as Java and C#, are hybrids in that they support both freestanding and class interfaces. A class interface in such languages contains all operations found in the freestanding interfaces implemented by the class, in addition to operations only accessible through the class interface.

This object model is unorthodox in that there are no class interfaces, and classes can thus not be used directly as types.1 The only means of accessing a class is through one of the freestanding interfaces it implements, which means that classes in this object model have been reduced to pure implementation entities. This means that only virtual operations are supported, thus necessitating the use of dynamic dispatch.

Footnotes

  1. Interfaces can, of course, be constructed that are identical to what a class interface would look like in Java, and be designated as such in the documentation.