Stereotype (UML)

from Wikipedia, the free encyclopedia

A stereotype (das; -s, -e; English stereotype ) is an extension of existing model elements in the Unified Modeling Language ( UML ). In practice, stereotypes primarily indicate the possible usage contexts (usage context) of a class, a relationship or a package.

Stereotypes are an important part of UML profiles , a lightweight mechanism for extending the UML metamodel. A stereotype specifies how a metaclass that has already been specified by the UML metamodel can be adapted for a specific area of ​​application.

Stereotype is not defined exactly the same in UML 1.x and UML2. This article refers to stereotype as it applies in UML2.

Stereotypes as special classes

Declaration of a stereotype

A stereotype is a special class . To distinguish it from other classes, the keyword is included stereotypebetween Guillemets ( «stereotype»). Like every class, it can have attributes which , in the case of stereotypes, are also referred to as tag definitions . The UML does not rule out that a stereotype can also declare operations , although operations on a stereotype are useless in that they never play a role in the application of the stereotype. Abstract stereotypes are allowed and often useful if several stereotypes are arranged in generalization hierarchies, whereby the restriction must be taken into account that stereotypes may only specialize other stereotypes, i.e. no other types of classes.

OrganisationsEinheitFor example, the stereotype in the illustration to the right includes two property definitions, namely kostenstelleand leiter.

Extension of metaclasses through stereotypes

Example of an extension of a metaclass with a stereotype

A stereotype always extends a model element of the UML, i.e. a metaclass from the UML metamodel. In order to model the relationship between a metaclass and a stereotype, the UML model element provides the extension (engl. Extension ) to a special form of association between the metaclass and the stereotype. An extension binds a metaclass and a stereotype into a bundle. Basically, an instance of the stereotype is always created when an instance of the metaclass is created in a UML model. This rule is only deviated from if the extension is marked as optional or if the stereotype is marked as abstract .

In the figure on the right, an extension of the metaclass Classthrough the stereotype is shown OrganisationsEinheitas a solid line with a closed arrowhead, but in contrast to the generalization , the arrowhead is filled.

An extension models the possibility of being able to apply a stereotype to a certain metaclass. Only if an extension is explicitly modeled in the profile to which the stereotype belongs, the stereotype may actually be applied to the corresponding metaclass within the scope of this profile. The stereotype OrganisationsEinheitfrom the example on the right should not be applied to a package because a package is not a class.

Apply stereotypes in a UML model

Example of an application of a stereotype

A UML model consists of instances of the metaclasses of the UML metamodel. If a profile is applied to a model, the stereotypes from this profile can be used according to their definition. OrganisationsEinheitFor example, because the stereotype Classextends the metaclass , it can be Finanzabteilungcombined with the class because it Finanzabteilungis an instance of the metaclass Class. In class diagrams , the name of the stereotype is shown enclosed by guillemets above the name of the element to which the stereotype is applied .

For each tag definition of the stereotype, a tagged value can now be added. Graphically, the property values ​​are drawn in a comment linked to the element to which the stereotype was applied.