Imagine the following case: I have a class Method and a class DataType. A method has one return type (if we count void as a return type) and zero to many parameters. Both the return type and the parameters are instances of the class DataType.
How would I model this Situation in a UML class diagram? One line for two references or one for each?
The best way would be to use role names instead:
Role names are explicit attributes in the opposite class, telling how the specific class is used. So Method.parameter
is of type DataType
.
Note that I changed the return type
to be 0..1
rather than 1
since your text tells that it's optional.