Interface (UML)

from Wikipedia, the free encyclopedia

An interface (. English interface ) is in the computer science a model element in the Unified Modeling Language (UML), a modeling language for software and other systems.

An interface declares a list of attributes , operations and signal receivers , all of which have public visibility.

UML2 differentiates between offered and required interfaces. An offered interface is an interface that a classifier , usually a class , implements and thus offers. A required interface is an interface that a classifier needs in order to perform its function.

When a classifier offers an interface , it assures two things: firstly, it declares that it will implement all operations of the interface and, secondly, it promises that it implements all attributes in a suitable manner. It is not mandatory that it has exactly the same attributes as the interface. It is sufficient for the classifier to simulate an attribute, for example with a pair of operations, with one operation simulating read access and the other simulating write access to the attribute. In this context, one speaks of a pair of setter and getter operations .

If an interface is required , these statements do not apply as a guarantee, but as a requirement. A classifier that requires an interface expects that the operations and attributes are made available in a suitable manner by a second classifier that implements the interface.

A UML model always shows that an interface is a offered or a required interface of a classifier as a dependency relationship between the classifier and the interface. In the case of the offered interface, it is an interface implementation relationship , and a required interface is a usage relationship . The two types of interfaces are shown differently and in different variants in a class diagram, whereby the underlying dependency relationships are not explicitly shown in every notation variant (see next section).

notation

Like a class , an interface is represented by a rectangle. Blue texts are explanatory comments and do not belong to the UML2 notation.

An interface is marked with the keyword «interface»

The two following figures show two options for displaying the interfaces offered.

Interface offered, shown with ball notation (also lollipop notation)
Offered interface, represented with an interface realization relationship

The two following figures show two options for representing the required interfaces.

Required interface, shown with socket notation
Required interface, represented with a usage relationship

Differences to UML 1.4

In UML 1.4 , the previous version of UML 2, there was also an interface model element . However, the modeling options have been significantly expanded in UML2. Well interfaces can also attributes and signal receiver included, as well as associations be connected to other interfaces.

Another new feature is the distinction between offered and required interfaces and the socket notation for required interfaces.

See also