tags:

views:

127

answers:

2

i want a notation for STL MAP in UML diagram.

+3  A: 

You can just treat it as a native data type. Most of the time there is no reason to do something else.

There is no 'right' or 'wrong' here. The only questions is what makes the architecture more understandable to the team.

Lior Kogan
I completely agree. Standards like UML try to define a set of standard rules that make it easier to explain an architecture (as a kind of collection of good practices or common sense). But in the end, it's your team that has to understand it, and if a deviation from the standards is needed to make it clearer, there's no need to stick to the standards. (I just realized: if we would all have sticked to the standards in computer history, we would still be using Cobol).
Patrick
+1  A: 

Depending on what you want to model and how. I have many times just modeled the composition/aggregation relationship of the class containing the map to the map stored elements and added an attribute to the relationship:

class MyEnclosingType {
   std::map<int,MyEnclosedType*> m_map;
};

MyEnclosingType <>-------------------------- MyEnclosedType
                         << map >>

Depending on the tool you are using, some do recognize it. For example BoUML, IIRC, will automatically draw something similar to this:

MyEnclosingType <>-------------------------- MyEnclosedType
                              ^
                              |
                              | << bind Key=int >>
                              |
                             map 

I don't think it was exactly like that, but somehow similar. At the end UML is a tool for people to read, not for computers. If you do believe in code generation (good luck) then the question is what strange construct you need to use for your software to understand your intentions.

Some other tools will have the STL or allow you to add parametrized types and you can use that to represent the same code as:

                                                 Key=string
                                                 Value=MyEnclosedType
MyEnclosingType <>-------------------------- map

Where both MyEnclosingType and map would be surrounded by solid boxes, and Key and Value would be represented by a discontinuous box overlapping the map box as with other parametrized types.

I would try to reverse engineer a simple code sample with a map with your tool of choice and see what the tool generates for you. If you don't like it, just think on what you can do to actually offer as much insight to the problem as you can with what the tools enables you to.

David Rodríguez - dribeas