How can I represent a member of a Map class in UML?

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 would rather treat the map as if it was a native type than a complex object.

Consider the following example

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

    private static Map<Searcher, Integer> searcherCache;
}

      

I would like to highlight the fact that it IndexManagerImpl

contains (albeit indirectly) references to instances Searcher

. It would be great if the view could also show type parameters searcherCache

.

+2


source to share


3 answers


Disagree with Martin ... MAP is the basic data structure that we learn in any computer course! It exists in most modern languages ​​and is an essential resource for analysts. The map can 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 boilerplate approach - it hides the associations between the major players. The last resource is ClassClass, a special UML class used to define nxn relationships with attributes, which I think suits your problem, where the "integer" field is some sort of Searchers counter associated with the indexManager. Remember also that you don't see the other side of the relationship in your code, while the UML is meant to show both sides, navigation problems, etc.



+2


source


In fact, collection objects indicate the relationship between the two classes. Therefore, the chart must have an IndexManagerImpl class that has a one-to-many association with the Searcher class.



0


source


Maps cannot be considered collections as they have different properties than collections. In fact, a map is a multiple of a collection with specific (cartographic) relationships. In my opinion, the map display is highly dependent on the requirement, and multiple UML map maps can be presented based on your requirement. Thus, a relationship to a map can be represented in a simple manner, from one to many associations with an element of a keyset and from one to one association of an element of a keyset to an element of value. Where the key element and values ​​are wrappers for the original elements, since the association is not really associated with the original elements.

Hope this helps ...

-1


source







All Articles