关联和依赖的区别? [英] Difference between association and dependency?

查看:37
本文介绍了关联和依赖的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 UML 类图中,关联关系和依赖关系有什么区别?

In a UML class diagram, what is the difference between an association relationship and a dependency relationship?

据我所知,关联是比依赖更强的关系,但我不确定它是如何更强的.

From what I know, an association is a stronger relationship than a dependency, but I'm not sure how it is stronger.

任何例子都非常受欢迎:)

Any example would be more than welcome :)

推荐答案

依赖和关联有什么区别?:

通常,您使用关联来表示字段之类的东西在一个班级.该链接始终存在,您可以随时询问为其客户订购.它实际上不需要是一个字段,如果你是从更多的界面角度建模,它可以只表明存在返回订单客户的方法.

In general, you use an association to represent something like a field in a class. The link is always there, in that you can always ask an order for its customer. It need not actually be a field, if you are modeling from a more interface perspective, it can just indicate the presence of a method that will return the order's customer.

引用 UML Distilled 的第 3 版(现在刚刚出版)a如果更改了定义,则两个元素之间存在依赖关系一个元素(供应商)可能会导致另一个元素(供应商)发生变化客户)".这是一个非常模糊和笼统的关系,这就是为什么UML 有许多不同形式的依赖的构造型.在代码方面,诸如命名参数类型和创建临时变量中的对象意味着依赖.

To quote from the 3rd edition of UML Distilled (now just out) "a dependency exists between two elements if changes to the definition of one element (the supplier) may cause changes to the other (the client)". This is a very vague and general relationship, which is why the UML has a host of stereotypes for different forms of dependency. In code terms, such things as naming a parameter type and creating an object in a temporary variable imply a dependency.

...

这篇关于关联和依赖的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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