By using the qualified association element of UML Class Diagram, we can create HashMap as the datatype of one of our class attributes (see here). In my case, I have to use HashMap with different key datatype (String and int) if the audience would be only with Java developers I would provide UML Class diagram as below:

enter image description here

and I guess this is just fine. However, my audience is unknown so I'm trying to provide a UML Class Diagram as general as I can. For example, the HashMap can be Dictionary in another programming language.

  • 2
    I'm not sure I understand your question. The Qualified Association, which you cited, is the implementation-independent way to represent it. See the other examples at uml-diagrams.org/property.html#qualifier – Fuhrmanator Jul 3 '18 at 15:33
  • @Fuhrmanator qualified associations are implementation independent, but I think the type HashMap<...,...> is not. – Christophe Jul 3 '18 at 22:07
  • Wouldn't this answer your question: stackoverflow.com/a/8870950/3723423 ? – Christophe Jul 3 '18 at 22:11
  • @Christophe I was thinking one does not specify attributes of a class when there is a qualified association. It's hard to reason about Strings and Class as types. – Fuhrmanator Jul 4 '18 at 0:54
  • @Fuhrmanator see here the part that explains that you can use an association end as an attribute (and making the bridge btw class and type): uml-diagrams.org/association.html – Christophe Jul 4 '18 at 4:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.