开发者

Is a notification from a subject to an observer a dependency?

开发者 https://www.devze.com 2023-01-26 01:32 出处:网络
If a class Foo observes another class FooBar, does Foo depend on FooBar? Is the opposite the same; does Foobar depend on Foo?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号