Operation (UML)

from Wikipedia, the free encyclopedia

An operation ( english surgery ) is a model element in the Unified Modeling Language (UML), a modeling language for software and other systems.

An operation is a behavioral characteristic that is used to model the way in which a behavior is invoked. It specifies the entry point into a behavior in the form of a signature . The behavior itself can be modeled independently of the operation and in different ways, for example as an activity , as an interaction or as a state machine . As a behavior characteristic, it belongs either to a class or to an interface .

specification

The specification of an operation basically consists of the name of the operation and a list of parameters . Like every feature, an operation can also specify details about visibility, multiplicity and the type of operation. The visibility of an operation is either public , private , protected or package (see also: data encapsulation ).

The multiplicity and the type of operation are specified indirectly. If the operation has a parameter with the direction return , then the multiplicity and the type of operation correspond to the multiplicity and the type of this parameter. The fact whether the return values ​​of the operation are ordered or unambiguous is derived from this parameter. The UML2 specifies that at most one parameter with the direction return may exist.

Analogous to class attributes, there are also class operations . They differ from the other operations in that they do not model the call of behavior on individual instances of the class, but on the class itself. Class operations, like class attributes, are underlined in the graph to separate them from normal operations.

Operations signature

The generic structure of an operation signature looks like this:

sichtbarkeit name(parameterliste): rückgabetyp {eigenschaft=wert}

sichtbarkeit, rückgabetypand eigenschaft/wertpairs are optional. If these details are of no interest in a visual representation, they can be hidden.

parameterlisteis either empty or consists of a list of ,parameter declarations separated by commas ( ) with the following generic structure:

richtung parametername: parametertyp [multiplizität]{eigenschaft=wert}

Here too richtung, parametertyp, multiplizitätand eigenschaft/wertpairs optional.

The direction determines whether it is an input or output parameter. The following values ​​are allowed.

direction description
in It is an input parameter that is used to pass data to the called operation.
out It is an output parameter that is used to return data to the calling operation.
inout The parameter is used to exchange data in both directions.
return The parameter accepts the return value of the operation. There can only be one return parameter per operation and only if the return value is not specified as a result type in the signature of the operation.

Examples

The following table shows three examples of operation signatures.

signature description
+buchen(betrag: Betrag) A public method buchenwith one parameter betrag. The operation has no return type.
-prüfeKontostand(in betrag: Betrag, in datum: Datum[0..1]):Boolean A private method prüfeKontostand. The second parameter datumis optional because it has the multiplicity 0..1.
listeBuchungen(von, bis): Buchung[*]{ordered}
A method listeBuchungenwith two parameters. The return type is Buchungand the operation returns any number of transactions in an ordered list.

Individual evidence

  1. Heide Balzert: UML 2 compact: with checklists . 2nd Edition. Elsevier, Spektrum, Akad. Verlag, Munich / Heidelberg 2005, ISBN 3-8274-1389-3 , pp. 12 .