I'm currently learning about coupling and dependencies in Java. I've been reading this tutorial and understand that if class1 contains an instance of class2 and if you call a method like exampleMethod(c2)
, this counts as dependency between class1 and class2. However, I am unsure about the examples below. Can anyone give me some clarification?
Assuming that we are inside class1 (which contains class2 c2
):
If class1 calls a method defined in class2 (
c2.aMethod()
for example), does this count as a dependency/coupling between class1 and class2?Does calling
c2.someSetterMethod(argument)
count as dependency/coupling between class1 and class2?Does calling
c2.repaint()
within class1 count as a dependency?