UML图:如果ClassA通过ClassB访问ClassC,那么ClassA到ClassC是否存在依赖关系?

huangapple go评论63阅读模式
英文:

UML diagrams: if ClassA accesses ClassC through ClassB, is there a dependency from ClassA to ClassC?

问题

例如,如果classA调用classB.getClassC().foo(),在ClassA和ClassB之间存在依赖关系,但ClassA和ClassC之间是否也存在依赖关系?

英文:

For example, if classA calls classB.getClassC().foo(), there is a dependency between ClassA and ClassB, but is there also a dependency between ClassA and ClassC?

答案1

得分: 1

> classA调用classB.getClassC().foo()

这两个调用都在class A的一个操作中完成,从class B的操作中获取C的实例并不会改变这一事实,所以class A使用了class C,您可以通过从A到C的依赖关系来表示这一点(如果没有出于其他原因的“更强”关系)。

在class A和class B之间,您没有提供足够的细节来了解是否存在关联还是仅有依赖关系。getClassC是class B的静态操作吗?否则,如果classB对应于B的实例,则您没有说明它是否是class A的属性,还是通过执行给定代码的操作的参数传递而获得的等等。

英文:

> classA calls classB.getClassC().foo()

both calls are done in an operation of the class A, the fact the instance of C is get from an operation of B changes nothing about that, so the class A uses the classes C and you can indicate that with a dependencies from A to C (if there is no 'stronger' relation for an other reason).

Between the class A and the class B you do not give enough detail to know if there is an association or just a dependency. Is getClassC a static operation of the class B ? Else if classB correspond to an instance of B you do not say if it is an attribute of the class A or received through a parameter of the operation doing the code you give etc

huangapple
  • 本文由 发表于 2020年10月5日 15:56:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/64204552.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定