类图中的HashMap(UML) [英] HashMap in class diagram (UML)

查看:459
本文介绍了类图中的HashMap(UML)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的Java应用程序构建UML 2.0类图。在我的代码中,我有HashMap数据类型的属性。但是,据我所知,在UML标准中没有HashMap数据类型。问题是 - 我可以使用HashMap作为类的属性的数据类型吗?



更新



也许在图中我只是应该指向java.util包?并且可能将Map类放在这个包中的图上?

解决方案

HashMap不应该出现在你的UML模型中。 HashMap只是一个合格关联的实现。可能它甚至只是一个提高速度的不合格协会。所以如果你有一个带有HashMap的类A,你可以建模一个UML Class A,一个UML Class B和一个从A到B的UML Association。如果通过一个不属于属性的键如果你的HashMap键是B的名字(而B有这个名字作为属性),你可以简单地省略这个限定词。



为了表示你的实现Association(你想用HashSet实现它),你可以添加它作为一个关键字或为它创建一个Stereotype(更复杂)。

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?

解决方案

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

这篇关于类图中的HashMap(UML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆