英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论