UML 类图关联属性 {subsets <关联结束 >} |{联合} |{重新定义} [英] UML class diagram association properties {subsets < Association end > } | {union} | {redefines}

查看:30
本文介绍了UML 类图关联属性 {subsets <关联结束 >} |{联合} |{重新定义}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当谈到 UML 中类图之间的关联时,我不太明白 {subset} 代表什么.我在第 4 页找到了这个关于它的 PDF:

我读了这篇文章,但我不是 100% 知道 {subsets <类 >} 是关于.它说表示 d 的槽将是表示 b 的槽的子集.类型 B 的元素可以插入到插槽 b 中,类型 D 的元素可以插入到插槽 b 和 d 中."那么,{subset} 是某种多态性吗?我认为通过插槽"它们的意思就像是类型 B 的方法的参数.并且因为 D 是 b 的子集,这意味着 D 就像 b 的子类,所以它可以作为b"传递下去.由于多态性而在争论中.

所以问题是:什么是{子集<类 >确切地说,它代表一个子类吗?

除此之外,我还有其他问题:什么是 {union},{redefines <类 >}, {非唯一} &{序列}.代表什么?

代码中的一些示例会更容易理解.

解决方案

所以问题是:什么是 {subsets <类 >确切地说,它代表一个子类吗?

它不是 {subsets <class >}{subsets <属性名称 >}

在给定的图中,D 是唯一一个专门用于 B 的可见类,如果它们不是专门用于 B 的其他类,那么所有实例BD 的实例,然后 {subset b} 等于 b.

但至少有:

B 的所有实例都不是 D 的必要实例(包括专用于 D 的类),这就是为什么 d 只涉及 b 所关注的 B 实例的一个子集.

在你的图表和我的图表中,子集并不是很有用,但是例如在重新定义的情况下,例如{子集a,重新定义a} {子集b,重新定义b}


<块引用>

什么是{union},{redefines <类 >}, {非唯一} &{序列}

参考 formal/2017-12-05 §9.5.4 第 113 和 114 页:

  • union 表示该属性是其子集的派生并集.

  • nonunique:表示多值属性中可能存在重复项.这与 unique 相反,意味着没有可能的重复.例如,假设 b{nonunique} 那么一些 B 的实例可以在 b 中出现多次.如果该属性在 C++ 中由 std::set 实现,则它是 {unique}.

  • sequence 表示该属性代表一个有序包,这是{nonunique,ordered}的快捷方式.这是 C++ 中 std::vectorstd::list 的情况.

  • {重新定义 <属性名称>}(不是{redefines < class >})意味着该属性重新定义了一个由<标识的继承属性.属性名称 >.如果在您的图表中 {subsets b} 被替换为 {redefines b} 那么类 C 只有插槽(例如 C++ 中的属性等)d.这不像有 b 私有所以不能从 C 访问,这真的意味着 d 是对 b 的重新定义.

I don't quite understand what {subset} stands for when it comes to the association between class diagrams in UML. I've found this PDF that talks about it on page 4: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.138.5537&rep=rep1&type=pdf. Here is the diagram & text that you can also find on page 4:

I read this and I'm not 100% about what {subsets < class > } is about. It says that "The slot representing d will be a subset of the slot representing b. Elements of type B can be inserted into slot b and elements of type D can be inserted into slots b and d." So, is {subset} some kind of polymorphism ? I think that thorugh "slot" they mean like the argument of a method that is of type B. And because D subsets b that means that D is like the sub-class of b so it can be passed down as "b" in arguments because of Polymorphism.

So the question is : What is {subsets < class > } exactly, is it representing a sub class ?

On top of that I have other questions: What are {union}, {redefines < class > }, {nonunique} & {sequence}. What do does stand for ?

Some examples in code would make it easier to understand.

解决方案

So the question is : What is {subsets < class > } exactly, is it representing a sub class ?

It is not {subsets < class >} but {subsets < property name >}

In the given diagram D is the only visible class specializing B, and if they are no other classes specializing B then all the instances of B are instances of D and then {subset b} is equal to b.

But having at least :

all the instances of B are not necessary instances of D (including of classes specializing D), this is why d only concerns a subset of the instances of B concerned by b.

In your diagram and mine the subsets are not really useful, but there are for instance in case of redefinition e.g. {subsets a, redefines a} {subsets b, redefines b}


What are {union}, {redefines < class > }, {nonunique} & {sequence}

referring to formal/2017-12-05 §9.5.4 page 113 and 114 :

  • union means that the property is a derived union of its subsets.

  • nonunique: means that there may be duplicates in a multi-valued property. This is the opposite of unique meaning there is no possible duplicates. For instance supposing b is {nonunique} then some instances of B can be present several times in b. If the property is implemented in C++ by a std::set it is {unique}.

  • sequence means that the property represents an ordered bag, this is a shortcut of {nonunique, ordered}. This is the case of std::vector and std::list in C++.

  • {redefines < property-name > } (not {redefines < class >}) means that the property redefines an inherited property identified by < property-name >. If in your diagram the {subsets b} is replaced by {redefines b} then the classes C only has the slot (e.g. attribute in C++ etc) d. This is not like having b private so not accessible from C, that really means d is a redefinition of b.

这篇关于UML 类图关联属性 {subsets &lt;关联结束 &gt;} |{联合} |{重新定义}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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