Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I put 'const' in my UML diagram?

Tags:

c++

uml

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?

like image 748
Pieter Avatar asked Nov 15 '10 13:11

Pieter


People also ask

Do you put constants in UML?

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.

Do you include constructors in class diagrams?

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.

Do you put constructors in UML?

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.


1 Answers

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.

like image 160
Bojan Komazec Avatar answered Oct 10 '22 12:10

Bojan Komazec