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

Viewed 35

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 Answers

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

Related