This is an old revision of the document!
Table of Contents
Interface
Meaning 1: Interface as a Concept
Alternative Terms
Definition
An interface defines the interaction between certain modules.
Description
Interface is a very general concept which refers to the interaction points of arbitrary modules:
- The interface of a method is defined by its method signature.
- The interface of a subsystem is defined by the public (facade) classes.
- The interface of a network service is defined by a protocol.
- The interface of a hardware component is defined by pins, wires, signals, protocols, etc.
- A graphical user interface is defined by buttons, menus, text boxes, and other controls.
The interface defines how a module shall be used. There may be ways circumventing the interface and accessing internal parts of a module directly. This should be avoided (IH/E) but is sometimes done.
A module can be described as having a provided interface and a required interface.
Examples
Alternative Definitions
See Also
Further Reading
Meaning 2: Interface as a Language Construct
Alternative Terms
Definition
An interface
is a language construct of certain object-oriented programming languages resembling an abstract class without any implementation.
Description
An interface
is similar to a class but does not contain any attributes or implementations—just method signatures. Typically object-oriented programming languages use interfaces
in order to avoid the problems of multiple inheritance, especially the diamond problem. In such languages a class can inherit from only one class but multiple interfaces. In that way there is only one implementation inherited.
There are interfaces
in Java, C#, Object Pascal/Delphi and possibly also in other languages.
Note that in this wiki whenever the language construct is meant (and not the concept) interface
shall be written using a monospace font: interface
vs. interface.
Examples
public interface Collection<E> extends Iterable<E> { boolean add(E e); boolean addAll(Collection<? extends E> c) void clear() boolean contains(Object o) ... }
Alternative Definitions
See Also
Further Reading
Other Meanings
- In Object Pascal a unit, i.e. a pas-file, typically contains an interface and an implementation section. The interface section lists the declarations which are visible outside the unit.