views:

40

answers:

2

Is there a standard representation for typed java collections in UML2? I am working on a class diagram and would like to avoid Java syntax, when using something like Map as type for a class attribute.

- foo : Map<Integer, String>
+3  A: 

UML2 has parameterized classes, and the syntax is in fact pretty much the same as Java's - both Java and the UML spec were inspired by the C++ syntax here.

Michael Borgwardt
Thanks, that was exactly what I was looking for!
Mobbit
+2  A: 

I'm against using too much design documents to program. Documents are only for communicating ideas, IMHO.

So if you need Java Types for your UML chances are:

  • you are reverse engineering: then Java Syntax will be fine

  • you are trying to program trhough UML: don't do it. Program in Java. Use UML only for object relation and collaboration

    • if the types are primitive: it's likely you don't need to express internal data structures in UML. You only need to express what's the responsibility of the class.
    • if the types are objects: ok, maybe it's the point... I'm not sure, but try to use the minimum...
helios