如果A仅在B的方法中使用,是否存在依赖关系?

发布于 2024-12-23 15:53:59 字数 255 浏览 1 评论 0原文

我有一个类 Idea 和类 Generator

在 Generator 的 run() 方法中,Idea 列表将是 < strong>构造并作为run()的返回值返回

我只知道如果Generator有一个成员是Idea列表,那么它们的依赖关系一定会存在。但我上面提到的情况又如何呢?

I have a class Idea and class Generator

In Generator's run() method, a list of Idea will be constructed and returned as return value of run()

I only know that if Generator has a member which is a list of Idea, their dependency relationship will exist certainly. But how about the situation I mentioned above?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

若相惜即相离 2024-12-30 15:53:59

在查看依赖项时,问问自己如果没有该特定类会发生什么。如果它无法运行/编译,则存在依赖性。所以是的,Generator 依赖于 Idea。

When looking at dependencies, ask yourself what would happen if you didn't have that particular class. If it wouldn't run/compile, then there is a dependency. So yes, Generator has a dependency on Idea.

染火枫林 2024-12-30 15:53:59

依赖关系显示在类图中的分类器级别。我的意思是,如果两个方法互相调用,那么就会存在依赖关系。您有不同类型的依赖项,这些依赖项通过依赖项链接和构造型(例如 <<)显示。致电>>等等..

下面是一个例子:
替代文本
(来源:forum-omondo.com

Dependencies are displayed at classifier level in the class diagram. I mean that if two methods call each other then there is a dependency. You have different kinds of dependencies which are displayed with a dependency link and a stereotype such as << call >> etc..

Below is an example:
alt text
(source: forum-omondo.com)

明明#如月 2024-12-30 15:53:59

您所描述的情况是遵循 create 构造型的 Usage 依赖项。这确实是一个典型的依赖示例,如下所示:

UML 中的依赖关系

The situation you are describing is a Usage dependency following the create stereotype. It is indeed a classic example of dependency, as noted here:

Dependency relationships in UML

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文