I'm making a UML diagram using Dia. Do I need to put const
in the diagram when a function is const
? If so, where?
Class (i.e. static) methods and fields are indicated by underlining. Constant (i.e. final) fields are indicated via naming convention: constants should be in ALL_CAPS.
In a class diagram, we list all class methods including the constructors; constructors are listed first and then all class methods. We also write the return type of a method in the class diagram.
A constructor is an operation within a UML class. It is annotated with «create» stereotype. A constructor is a special operation (or method) that is used to initialize a class instance. A constructor may be parameterless or it may include a list of parameters that have to be set to initialize a class instance properly.
Chapter 11.8.2 ("Operation") in the latest UML specification lists isQuery as one of the operation's attributes:
isQuery : Boolean - Specifies whether an execution of the Operation leaves the state of the system unchanged (isQuery=true) or whether side effects may occur (isQuery=false). The default value is false.
If operation that does not change system's state is shown in a diagram, property {query} should be added after function's return type.
Dia supports isQuery attribute for class' operations: open class' Properties window and in Operations tab tick Query checkbox for method that does not change class' state and const will appear after method's return type in a diagram.
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