views:

296

answers:

2

When I have a class with a Map member, I don't want to draw a separate class/interface object to represent the Map itself, but I'd prefer to treat the map as if it was a native type, rather than a complex object.

Consider the following example

public class IndexManagerImpl implements IndexManager {
    /* ... */

    private static Map<Searcher, Integer> searcherCache;
}

I'd like to highlight the fact that an IndexManagerImpl holds (although indirectly) references to Searcher instances. It would be great if the representation could also show the type parameters of searcherCache.

A: 

Actually collection objects indicate a one-to-many association between two classes. Therefore you should have a IndexManagerImpl class on your diagram that has a one-to-many association with a Searcher class

Beatles1692
I'd agree with you and use a one-to-many association if I had to deal with a plain list (or a set, as well).A map is, in my opinion, more complicated with that: if I used an association I'd lose the key-value nature of maps.
abahgat
I'm not sure if there's a standard way to show a map as an association but I think you can use a stereotype to create a custom association type for maps
Beatles1692
A UML model is an abstraction and should not be tied to a language idiom. In this case MAP is a language idiom (a built in part of Java). Most tools support the use of Profiles for implementation languages, that will provide the built in complex types.
Martin Spamer
+2  A: 

A disagree with Martin... MAP is basic data structure that we learn in any computer graduation course! It exsists in most modern languages and is an important design resource for analysts. A Map may be drawn as an association in some situations, but some kind of extension (stereotypes) will be needed OR you can define a template class. I don't like the template approach - it hides the associations btw the major players. The last resource is the AssociationClass, a special UML class used to define nxn relations with attributes, what I think suits your problem, where the "integer" field is some kind of counter of Searchers related to the indexManager. Remember also that by code you can't see the other side of the relationship, while UML is designed to show both sides, navigation issues and so forth.

Alex