我和我的同事在一点上无法达成一致。在 UML 中,进行聚合时,菱形边的重数是否为 1 最大值,或者可以为 0..* ?还是取决于观点?
先感谢您 !
2 回答
首先,您需要具体说明您的意思是哪个“钻石”作为聚合中的空钻石和填充钻石是组合?
如果您的意思是空钻石,那么 Icepack 是正确的,并且您混淆了 2 个不同的东西。 多重性与聚合无关,因此“菱形”聚合指标可以具有您喜欢的任何多重性,因为它们是不相关的。
If you mean filled diamond ie composition then the example someone has posted won't really help you as it's saying: "There are many departments but only 1
University (multiplicity)" and that "if all departments are deleted then University is also deleted (composition)".
I am struggling to think of a good example where composition end wouldn't be 1 only
and as far as I can think it would never be 0..*
as you can have a class which has to delete something which may not ever exist? I could however be 1..*
ie many to many, for example Exam and Exam Questions.
多重性可能是1..*
即1..*
考试有1 or more
问题并且问题可以存在于1 or more
考试中。考试结束时填充菱形(作文)意味着如果所有问题都被删除,那么所有考试也将被删除
是的,它可以是 0..*。这里有一个很好的例子:系有几个教授,每个教授可能同时属于几个系。