不了解关系之间的区别
在这里,我有此类图:
这是我不理解的事情:
- 为什么
order
-OrderDetail
聚合?不应该只是关联,因为它将具有list< orderdetail>
喜欢:
public Order{
public DateTime date;
public Status status;
public List<OrderDetail> orderDetails;
}
- 为什么
orderdetail
-item
item a的依赖关系?它不应该是关联,因为它有对该item
类的引用?
图的参考: http://ssslabmcs12.weeebly.com/Resources/Resources1.html
Here I have this class diagram:
Here are the things that I don't understand:
- Why is
Order
-OrderDetail
an aggregation? Shouldn't it just be an association, since it will have aList<OrderDetail>
like:
public Order{
public DateTime date;
public Status status;
public List<OrderDetail> orderDetails;
}
- Why is
OrderDetail
-Item
a dependency? Shouldn't it be association since it has a reference to thatItem
class?
Reference for the diagram:
http://sslabmcs12.weebly.com/resources1.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
共享聚合
,它没有定义的语义。参见p。 UML 2.5的110:因此,您最好询问图表作者有关他的意图。
OrderDetail
可以看到item
,但反之亦然。最好仅在一侧使用角色名称来表达这一事实。例如,仅在右侧放置item
,而左侧没有任何内容。我们能学到什么? UML是关于沟通的!
shared aggregation
which has no defined semantics. See p. 110 of UML 2.5:So you best ask the diagram author about his intentions.
OrderDetail
can seeItem
but not vice versa. A fact that could better be expressed by using role names only at one side. E.g. placingitem
only on the right hand side and nothing to the left.What can we learn? UML is about communication!