Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to represent enumeration classes with methods in UML class diagram

I have an enumeration class that has a method in the class body, how do I represent this in a UML class diagram? Is the following a valid way? (It seems reasonable but I couldn't find anyone doing this online.)

enter image description here

like image 575
Clare Avatar asked Oct 15 '25 17:10

Clare


2 Answers

In UML an enumeration is a classifier, so it can have operations.

As strange as it feels, the compartment with the litterals should be below the compartment with the operations (see UML 2.5 specifications, section 10.2.4, emphasis added by me):

The name of the Enumeration is placed in the upper compartment with the keyword «enumeration» above or before the name. A list of EnumerationLiterals may be placed, one to a line, in a compartment named “literals” below the operations compartment. The attributes and operations compartments may be suppressed, and typically are suppressed and empty.

like image 188
Christophe Avatar answered Oct 18 '25 15:10

Christophe


Yes, that would be ok. An UML Enumeration is a DataType and that can have operations as well. See p. 165 of UML 2.5. And on p. 166:

A compartment listing the Operations is placed below the attribute compartment.

like image 30
qwerty_so Avatar answered Oct 18 '25 15:10

qwerty_so



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!