Reputation: 183
How would I display the field
private static final int DAMAGE = 3;
in the UML Diagram?
Should it be shown as: - DAMAGE : 3 : int
?
Upvotes: 15
Views: 66138
Reputation: 18568
For an UML representation of a Java project, it should be sufficient to write underlined caps, like…
Note that this representation uses a Java convention (constants written in capitals) to highlight it as final
instead of a UML annotation, which would be kind of more straight-forward UML, but is too long for my purposes.
Upvotes: 7
Reputation: 36305
You show it like this.
Private
is symbolized by a minus. The static
attribute is shown by an underline. The initial value is shown by = <value>
. Since I learned that final
denotes a constant, you will apply the isConst
property which is shown as {readOnly}
.
See also p. 111 of the UML spec:
<property> ::= [<visibility>] [‘/’] <name> [‘:’ <prop-type>] [‘[‘ <multiplicity-range> ‘]’] [‘=’ <default>] [‘{‘ <prop-modifier > [‘,’ <prop-modifier >]* ’}’]
[ details omitted ]
No longer relevant in this context, but leaving it anyway:
Re. @granier's comment about tagged values: Indeed UML 2.5 does no longer really use tagged values. There are only 3 mentions of it:
mainly p. 205
Just like a Class, a Stereotype may have Properties, which have traditionally been referred to as Tag Definitions. When a Stereotype is applied to a model element, the values of the Properties have traditionally been referred to as tagged values.
So tagged value is an "ancient" term and should further be called stereotype property.
Upvotes: 19