Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

Maps cannot be considered collections as they have different properties than collections. Actually a map is multiple of collection with specific (mapping) relationship. In my view representing map is highly dependent on the requirement and there could be several map UML representation based on your requirement. Thus in a simple form map relationship can be represented, one to many association to key set element and one to one association of keyset element to value element. Where key element and value element are wrappers to original elements as association are not actually with the original elements.

Hope this helps....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top