Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to describe a contained map in UML class diagram?

Tags:

I have a MyServer class that contains a Map whose keys are MyClientType objects and whose values are MyClient objects. I'd like to depict this relationship in a class diagram but I can't figure out a clean way to do that.

like image 250
elifiner Avatar asked Jul 28 '09 08:07

elifiner


People also ask

How do you describe a UML diagram?

A UML diagram is a diagram based on the UML (Unified Modeling Language) with the purpose of visually representing a system along with its main actors, roles, actions, artifacts or classes, in order to better understand, alter, maintain, or document information about the system.

What does a +/- symbol mean in an UML diagram?

The plus signs indicate the means you must use to interact with the properties and methods of the class. In other words, the Public items of a class define the interface for the class object and how you must interact with it.


1 Answers

You can use a qualified association:

┌──────────┐             1 ┌───────┐ │ MyServer │Key│───────────│ Value │ └──────────┘               └───────┘ 

See: http://etutorials.org/Programming/UML/Chapter+6.+Class+Diagrams+Advanced+Concepts/Qualified+Associations/ (cause it is hard to draw using ASCII)

Note also that a qualified association changes the multiplicity:

┌──────────┐          0..* ┌───────┐ │ MyServer │───────────────│ Value │ └──────────┘               └───────┘  ┌──────────┐             1 ┌───────┐ │ MyServer │Key│───────────│ Value │ └──────────┘               └───────┘ 

The top illustrates an association from a server to 0-n values. By contrast, the qualified association says that any given key will be associated with only one value, and that you can't have a key an absent value.

like image 133
Kru Avatar answered Sep 20 '22 13:09

Kru