18.6. Attribute

Attribute is a named slot within a class (or other Classifier) describing a range of values that may be held by instances of the class. In the UML metamodel it is a sub-class of StructuralFeature which is itself a sub-class of Feature.

An attribute is represented in the diagram on a single line within the attribute compartment of the class. Its syntax is as follows:

visibility attributeName : type [= initialValue]

visibility is +, #, - or ~ corresponding to public, protected, private, or package visibility respectively.

attributeName is the actual name of the attribute being declared.

type is the type (UML datatype, class or interface) declared for the attribute.

initialValue is any initial value to be given to the attribute when an instance of the class is created. This may be overridden by any constructor operation.

In addition any attribute declared static will have its whole entry underlined on the diagram.

18.6.1. Attribute Details Tabs

The details tabs that are active for attributes are as follows.

ToDoItem

Standard tab.

Properties

See Section 18.6.2, “Attribute Property Toolbar” and Section 18.6.3, “Property Fields For Attribute” below.

Documentation

Standard tab. See Section 13.4, “Documentation Tab”.

Source

Standard tab. This contains a declaration for the attribute.

Constraints

Standard tab. There are no standard constraints defined for Attribute within the UML metamodel.

Tagged Values

Standard tab. In the UML metamodel, Attribute has the following standard tagged values defined.

  • transient.

  • volatile. This is an ArgoUML extension to the UML 1.4 standard to indicate that this attribute is realized in some volatile form (for example it will be a memory mapped control register).

[Note]Note

The UML Element metaclass from which all other artifacts are derived includes the tagged element documentation which is handled by the documentation tab under ArgoUML

Checklist

Standard tab for a Attribute.

18.6.2. Attribute Property Toolbar

Go up

Navigate up through the package structure.

New attribute

This creates a new attribute within the owning class of the current attribute, navigating immediately to the properties tab for that attribute.

[Tip]Tip

This is a very convenient way to add a number of attributes, one after the other, to a class.

New Datatype

This creates a new Datatype (see Section 16.3, “Datatype”) for the selected attribute, navigating immediately to the properties tab for that datatype.

New Stereotype

This creates a new Stereotype (see Section 16.5, “Stereotype”) for the selected attribute, navigating immediately to the properties tab for that stereotype.

Delete

This deletes the attribute from the model

[Warning]Warning

This is a deletion from the model not just the diagram. If desired the whole attribute compartment can be hidden on the diagram using the style tab (see Section 18.6.2, “Attribute Property Toolbar”) or the button 2 pop up menu for the class on the diagram.

18.6.3. Property Fields For Attribute

Name

Text box. The name of the attribute. The name of a attribute has a leading lower case letter, with words separated by “bumpy caps”.

[Note]Note

The ArgoUML critics will complain about attribute names that do not have an initial lower case letter.

Stereotype

Drop down selector. There are no UML standard stereotypes for Attribute.

Navigate Stereotype

icon. If a stereotype has been selected, this will navigate to the stereotype property panel (see Section 16.5, “Stereotype”).

Owner

Text box. Records the class which contains this attribute.

Button 1 double click on the entry will navigate to the class.

Multiplicity

Editable drop down selector. The default value (1) is that there is one instance of this attribute for each instance of the class, i.e. it is a scalar. The drop down provides a number of commonly used specifications for non-scalar attributes.

[Note]Note

ArgoUML presents a number of predefined ranges for multiplicity for easy access. The user may also enter any user defined range that follows the UML syntax, such as “1..3,7,10”.

The value 1..1 is equivalent to the default (exactly one scalar instance). The selection 0..1 indicates an optional scalar attribute.

Type

Drop down selector. The type of this attribute. This can be any UML Classifier, although in practice only Class, DataType, or Interface make any sense.

[Note]Note

A type must be declared (it can be void). By default ArgoUML supplies int as the type.

Navigate Type

icon. This will navigate to the property panel for the currently selected type. (see Section 18.5, “Class”, Section 18.3, “Datatype” and Section 18.15, “Interface”).

Initial Value

Text box with drop down. This allows you to set an initial value for the attribute if desired (this is optional). The drop down menu provides access to the common values 0, 1, 2, and null.

[Caution]Caution

Any constructor operation may ignore this initial value.

Visibility

Radio box, with entries public, private, protected and package.

  • public. The attribute is available to any artifact that can see the owning class.

  • private. The attribute is available only to the owning class (and any inner classes).

  • protected. The attribute is available only to the owning class, or artifacts that are subclasses of the owning class.

  • package. The attribute is available only to artifacts contained in the same package.

Changeability

Radio box, with entries addOnly, changeable, and frozen.

  • addOnly. Meaningful only if the multiplicity is not fixed to a single value. Additional values may be added to the set of values, but once created a value may not be removed or altered.

  • changeable. There are no restrictions of modification.

  • frozen. Also named “immutable”. The value of the attribute may not change during the lifetime of the owner class. The value must be set at object creation, and may never change after that. This implies that there is usually an argument for this value in a constructor and that there is no operation that updates this value.

Static

Check box for static. If unchecked (the defaults) then the attribute has “instance scope”. If checked, then the attribute is static, i.e. it has “class scope”. Static attributes are indicated on the diagram by underlining.