javadictionaryumlobjectaid

Representation of maps in UML diagrams using ObjectAid plugin in Eclipse


How can I depict "map" collections within UML diagrams using ObjectAid UML plugin for Eclipse?

Example:

Class MyDatabase {
   Map<Integer, Person> db;
}

The map uses an Integer as the key element, and Person objects as values. But when I use ObjectAid to generate the UML diagram, I just get the MyDatabase class and the Person class linked by an arrow. That look likes a simple attribute of type Person, not a map.

I know UML is not about implementation details, but I would like to depict such relation (a map as an attribute). Ideas?


Solution

  • ObjectAid has actually done almost good job. :)

    Map is a kind of collection. Collections are in UML modelled using associations with the corresponding end 0..n, 1..n, 2..10 or similar. They can further be marked as "ordered" (a Vector for example) or to "allow duplicates", to cover all different kind of collections in different languages.

    Back to your example... In order to model a Map there is a UML concept called qualifier. An extract from UML spec:

    A qualified Association end has qualifiers that partition the instances associated with an instance at that end, the qualified instance. Each partition is designated by a qualifier value, which is a tuple comprising one value for each qualifier. The multiplicities at the other ends of the association determine the number of instances in each partition. So, for example, 0..1 means there is at most one instance per qualifier value. If the lower bounds are non-zero, the qualifier values must be a finite set, for example because the qualifiers are typed by enumerations.

    Please refer to UML specification for more.

    And here is how it looks like. This diagram fully reflects your code (even the collection name is there, modelled as association's end name):

    enter image description here