Closed junghon3709 closed 3 years ago
According to the code, I don't believe there is a reference from the Observer to the Activity. This was kind of the point of the Observer pattern where there is no need for the Observer to have a dependency to Observed (UiWidget in this case), rather the Observed only needed to have a dependency to the Observer interface.
I see, thanks!
According to the code, I don't believe there is a reference from the Observer to the Activity.
Yup, that's correct. Thanks @yucheng11122017
This was kind of the point of the Observer pattern where there is no need for the Observer to have a dependency to Observed (UiWidget in this case), rather the Observed only needed to have a dependency to the Observer interface.
Actually, the point of the patterns is to avoid the Observed class (i.e., Activity
) having to know about the Observer class (i.e., UiWidget
) and yet to be able to communicate with Observers. In this case, in spite of the a1:Activity
-> u:UiWidget
navigability, the class Activity
is unaware of the UiWidget
class (as per the class diagram).
It is mentioned that
a1 and a2 are both being watched by UiWidget object u
in Part 2 of the practise exam uploaded. So shouldn'ta1
anda2
be navigable fromu
? So shouldn't the arrow be fromu
toa1
anda2
instead?