How to Val and Var

How can we show, in our class diagram, that a field within a class is strictly mutable or immutable using var and val?

Hi,

you do not need to show if your fields within a class diagram are var or vals!

However in case you are using lists or maps, or any other datatype that could me immutable or mutable, you have to clearly state in the type, if it is a MutableList or just a List.

Example: breads: List<Bread> or breads: MutableList<Bread>

8 Likes

I understand, what if our design is dependent on that kind of separation? What is the best way to indicate it?

1 Like

Hi,

In the UML diagram you do not have to indicate if it is a var or val!

7 Likes