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

Categories

0 votes
826 views
in Technique[技术] by (71.8m points)

java - HashMap in class diagram (UML)

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

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

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...