UML关联类-澄清 [英] UML association class - clarifying

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

问题描述

我正在阅读"UML蒸馏",由Martin Fowler撰写,在阅读有关关联类的文章时,我得到了这句话:

I am reading "UML distilled" by Martin Fowler, and during reading about association classes I got this quote:

您可以从关联类中获得什么好处来抵消您必须要添加的额外符号

What benefit do you gain with the association class to offset the extra notation you have to

还记得吗?关联类增加了一个额外的约束,因为只能有一个实例

remember? The association class adds an extra constraint, in that there can be only one instance of

任何两个参与对象之间的关联类.

the association class between any two participating objects.

然后有一个示例,但是我想确保我理解正确,例如:

Then there was an example, but I want to make sure I got this right, if for example I got:

 ---------            ---------
|         |*        *|         |
| CLASS A |----------| CLASS B |
|         |     |    |         |
 ---------      |     ---------
                |
          ______|______
         |             |
         |             |
         |  CLASS C    |
         |             |
         |_____________|

然后,对于每个不同的对(A实例,B实例),仅存在一个C类实例.

then, for every distinct pair (instance of A,instance of B) there exists only one instance of class C.

因此,如果我采用A1,A2,B1,B2实例,那么对于(A1,B1)(A1,B2)(A2,B1)(A2,B2),我将得到4个C实例,仅此而已,仅此而已?

So if I would take A1,A2,B1,B2-instances then for (A1,B1) (A1,B2) (A2,B1) (A2,B2) I would get 4 instances of C, nothing less, nothing more?

推荐答案

这是正确的,此处无意混用概念,但与数据库中的表类似:

That'd be correct, without any intention to mix concepts here but it's similar to Tables in a database where:

A 1-* C
B 1-* C

其中C可以看作是打破了A和B之间多对多关系的结果.

Where C can be seen as the result of breaking a many to many relationship between A and B.

对于B上的每一行只能存在1,而C只能存在1行,并且(C上的)特定行只能与A上的1行相关.因此,对于A和B上的每一对唯一行,在C上只能存在1行,否则就不存在,因为*表示0或更多.

For each row on B can only exist 1 and only 1 Row C and That Particular row (on C) can only me related to 1 row on A. Hence, for each Pair of unique rows on A and B can only exist 1 row on C or none, because the * indicates 0 or more.

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

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