uml中,依赖 和 关联 有什么区别吗

来源:百度知道 编辑:UC知道 时间:2024/05/18 09:43:19
uml中,依赖 和 关联 有什么区别吗
个人觉得,关联==依赖呀
请取一个例子解释不同
10分

这个是C/C++,这个俺不懂,给你找了两篇文章,希望有帮助。

1.
A dependency exists between two elements if changes to the definition of one element (the supplier) may cause changes to the other (the client). With classes, dependencies exist for various reasons: One class sends a message to another; one class has another as part of its data; one class mentions another as a parameter to an operation. If a class changes its interface, any message sent to that class may no longer be valid.

如果两个元素其中一个的定义发生改变则会引起另一个元素发生变化则称这两个元素之间存在依赖关系,对于类来说,依赖可能存在于下列几种情况中:一个类要发送消息给另一个类;一个类将另一个类作为其数据的一部分;一个类的操作中将另一个类作为其参数。如果一个类改变了接口,则任何发送给该类的消息可能不再有效了。

关联在该书中没有这样去定义,作者列举了一个例子说明了双向关联的含义,汽车和车主类的实现。在汽车类中包含了车主成员,反过来车主类中也包含了其拥有的汽车成员集合,他们之间形成了双向关联。

这里是原文关于双向连接核心的描述:A bidirectional association is a pair of properties that are linked together as inverses. The inverse link between them implies that if you follow both properties, you should get back to a set that contains your starting poi