Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I build UML 2.0 class diagram for my Java application. In my code I have attribute with HashMap datatype. But, as I know, there is no HashMap datatype in UML standard. The question is - can I use HashMap as datatype for attribute of the class?

UPDATE

maybe in diagram I just should point to java.util package? and maybe place Map class in this package on the diagram?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
824 views
Welcome To Ask or Share your Answers For Others

1 Answer

HashMap should not appear in your UML model anyway. HashMap is just an implementation of a qualified association. Probably it's even just a speed improved unqualified association. So if you had a Class A with a HashMap you would model a UML Class A, a UML Class B and a UML Association from A to B. You can add a qualifier to the association if it's qualified by a key which is not an attribute of B. If your HashMap key is the name of B (and B has that name as an attribute) you would simply omit the qualifier.

To denote the implementation of your Association (you want to implement it with a HashSet) you can add that as a keyword or create a Stereotype for it (more complex).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...