Prev | Next |
Interface
Description
An Interface is a specification of behavior (or contract) that implementers agree to meet. By implementing an Interface, Classes are guaranteed to support a required behavior, which enables the system to treat non-related elements in the same way; that is, through the common interface. You also use Interfaces in a Composite Structure diagram.
Interfaces are drawn in a similar way to a Class, with operations specified, as shown here. They can also be drawn as a circle with no explicit operations detailed - right-click on the element and select the 'Use Circle Notation' option to switch between styles. Realize connectors to an Interface drawn as a circle are drawn as a solid line without target arrows.
An Interface cannot be instantiated (that is, you cannot create an object from an Interface). You must create a Class that 'implements' the Interface specification, and in the Class body place operations for each of the Interface operations. You can then instantiate the Class.
Toolbox icon
Learn more
OMG UML Specification:
The OMG Unified Modeling Language specification, (v2.5.1, p.171) states:
An Interface is a kind of Classifier that represents a declaration of a set of public Features and obligations that together constitute a coherent service. An Interface specifies a contract; any instance of a Classifier that realizes the Interface shall fulfill that contract. The obligations associated with an Interface are in the form of constraints (such as pre- and postconditions) or protocol specifications, which may impose ordering restrictions on interactions through the Interface. Interfaces may not be instantiated. Instead, an Interface specification is implemented or realized by a BehavioredClassifier, which means that the BehavioredClassifier presents a public facade that conforms to the Interface specification.
NOTE. A given BehavioredClassifier may implement more than one Interface and that an Interface may be implemented by a number of different BehavioredClassifiers. Interfaces provide a way to partition and characterize groups of public Features and obligations that realizing BehavioredClassifiers shall possess.
An Interface does not specify how it is to be implemented, but merely what needs to be supported by realizing BehavioredClassifiers. That is, such BehavioredClassifiers shall provide a public façade consisting of attributes, Operations, and externally observable Behavior that conforms to the Interface.