Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UML diagram - how to show FINAL

Tags:

java

uml

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.

like image 982
Istiak Khan Avatar asked Dec 01 '17 07:12

Istiak Khan


2 Answers

You show it like this.

enter image description here

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.

like image 126
qwerty_so Avatar answered Oct 01 '22 03:10

qwerty_so


For an UML representation of a Java project, it should be sufficient to write underlined caps, like…

A constant in a UML class diagram

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.

like image 33
deHaar Avatar answered Oct 01 '22 02:10

deHaar