How would I indicate a
"private static final int DAMAGE = 3;" in a uml diagram?
Would it show up as : - DAMAGE : 3 : int
Any help would be appreciated.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With