Attribute (UML)

from Wikipedia, the free encyclopedia

An attribute ( English attribute ) is a term used in the Unified Modeling Language (UML), a modeling language for software and other systems.

An attribute is a structural characteristic of a class and thus specifies part of the structure of objects that are formed for this class. It has a name and a type. For example, if a class has Kontoan attribute with the name saldoof type Integer, Kontoa corresponding balance value will be listed in the structure of each object of . With UML 2.0, every typed attribute can be understood as a directed association to the corresponding class (as a simple data type or reference type) with the role identifier as an attribute name and represented in the graphic notation in an equivalent manner.

An attribute is not an independent model element in the metamodel of UML 2, but a role that a so-called property ( Property can play) in a class.

Multiplicities

An attribute has a multiplicity that is specified by a lower and an upper limit.

The standard value for the multiplicity is 1 for the lower and the upper limit. When specifying an attribute, one can deviate from these standard values. This expresses that an instance of the class does not have exactly one value for this attribute, but a number of values ​​that lie somewhere between the lower and the upper limit.

An optional attribute is an attribute with multiplicity 0..1. A multi-valued attribute is an attribute with an upper bound greater than 1. With a multi-valued attribute, you can specify whether the values ​​of the attribute are ordered ( isOrdered ) or not. The default is unordered. You can also specify whether each value may appear at most once in the values ​​of an attribute ( isUnique ).

Attributes with read-only access and derived attributes

An attribute can only be read if the isReadOnly property is set to true . Without a corresponding declaration, write and read access are meant.

An attribute is derived ( isDerived ) if the values ​​of the attribute are (can) be calculated from the values ​​of other attributes. In the graphic notation, a derived attribute is marked with a preceding slash.

Attributes for instances and for classes

Defined in the context of a class, attributes usually describe instances of that class, not the class itself. Attributes that describe the class are called class attributes . They differ from the other attributes in that the isStatic property of the attribute is set to the value true . In the graphic notation, class attributes are underlined.

notation

Blue texts in the following figures are explanatory comments and do not belong to the UML2 notation.

Attributes are listed in a class's rectangle in a special section.

Simple example of a class with two attributes

The following illustration shows a class with two attributes decorated with different notation details.

Two attributes with notation details for multiplicities, read-only attributes, and ordered attributes

The following figure shows a class with a class attribute that has an initial value . Class attributes are underlined to separate them from the other attributes.

Example of a class attribute with an initial value

Differences to UML 1.4

The concept of the multiplicity of attributes has been simplified in UML2. In UML 1.4, the multiplicity of an attribute could consist of several unrelated number segments, for example 0..5, 9..*, all numbers without 6, 7 and 8. In UML2, several areas with a lower and an upper limit are no longer possible. The multiplicity must consist of exactly one connected range of numbers.

The concept of a read-only attribute already existed in UML 1.4, but there it is not specified with the isReadOnly property , but with the changeability = frozen property . Similarly, an ordered attribute was not declared with isOrdered , but with ordering = ordered .

The concept of a derived attribute is also known from UML 1.4. However, the corresponding attributes could only be marked visually there. An isDerived property did not exist.

Class attributes were also known in UML 1.4. However, they were differentiated there from attributes for describing instances by setting the ownerScope property to the classifier value .