Is a notification from a subject to an observer a dependency?
If a class Foo
observes another class FooBar
, does Foo
depend on FooBar
? Is the opposite the same; does Foobar
depend on Foo
?
Does dependency refe开发者_高级运维r to compilation dependency, or run-time functional dependency?
No, there is a no dependency from observer to subject. Observers merely contain behaviour that allows for them to be notified of changes. Anyone can provide that notification service. There is no type of dependency in that direction.
The subject has a dependency only on an abstract observer, and need not (and should not) depend on concrete implementations of observers.
精彩评论