class ConcreteObserver implements Observer {
String text;
public void actualize(Subject subject) {
this.text = subject.getState();
}
}
In other words, does the code above make my Subject coupled to Observer in the same way as if I did this?
class ConcreteObserver implements Observer {
String text;
Subject subject;
public void actualize() {
this.text = subject.getState();
}
}
all of the following relationships are counted as coupling:
so
ConcreteObservercoupled to theSubjectin both cases. (and nothing can be said about stated in the questionSubject's coupling toObserver)the second case decouples parent
ObserverfromSubject, but IMO explicit dependency is better than faking the scope with implicit.