Search code examples
umlclass-diagram

represent random attribute initialization


I am creating a class diagram where one of the attributes is initialized to a random value. What is the convention in a class diagram for showing that an attribute is initialized to a random value?


Solution

  • In UML, the default value of an attribute is a so-called ValueSpecification, which includes among others literal values (String, Number, ...),

    enter image description here

    as well as Expressions/OpaqueExpressions where you can specify an expression in some language, include programming and natural ones.

    enter image description here

    For further reading see Chapter 8 - Values in UML Specs