UML class diagram - represent attribute with initial value

14,573

The initial value of an attribute in a UML class diagram is represented just like variable assignment in a language like Java.

enter image description here

Moreover, since the example attribute is static, it should be underlined. Capitalization is by language or other convention and is not a UML specification.

Share:
14,573
ThisClark
Author by

ThisClark

Defense Against the Dark Arts Teacher

Updated on June 08, 2022

Comments

  • ThisClark
    ThisClark almost 2 years

    How is an attribute with initial value (such as a static constant) represented in UML?

    public class Foo {
        public static final int BAR = 17;
    }
    
  • Geert Bellekens
    Geert Bellekens about 8 years
    UML does not say anything about capitalizing names of constants.
  • Oliver
    Oliver over 3 years
    Out of curiosity, what software are you using?
  • ThisClark
    ThisClark over 3 years
    That screenshot I'm pretty certain came from Microsoft Visio 2010. Nowadays I would go for the free and less capable Lucidcharts. I never need UML outside of teaching
  • Alan
    Alan over 3 years
    @ThisClark plantuml is an interesting alternative for simple diagrams. (It is text based, with automated layout.)