如果A仅在B的方法中使用,是否存在依赖关系?
我有一个类 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在查看依赖项时,问问自己如果没有该特定类会发生什么。如果它无法运行/编译,则存在依赖性。所以是的,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.
依赖关系显示在类图中的分类器级别。我的意思是,如果两个方法互相调用,那么就会存在依赖关系。您有不同类型的依赖项,这些依赖项通过依赖项链接和构造型(例如 <<)显示。致电>>等等..
下面是一个例子:
(来源: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:
(source: forum-omondo.com)
您所描述的情况是遵循 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