A
Alan Isaac
I have two questions about the "observer pattern" in Python.
This is question #1. (I'll put the other is a separate post.)
Here is a standard example of the observer pattern in Python:
http://en.wikipedia.org/wiki/Observer_pattern
Contrast with this rather standard discussion:
http://www.dofactory.com/Patterns/PatternObserver.aspx#_self1
The difference I am focusing on is that in the latter,
the observer (investor) maintains a reference to the
subject (stock).
(Many questions can be raised of course: see the discussion at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/131499).
Is anything lost by not maintaining this reference (other
than error checking ...)? If I feel the observer needs
access to the subject, what is wrong with just having the
subject pass itself as part of the notification?
Thank you,
Alan Isaac
This is question #1. (I'll put the other is a separate post.)
Here is a standard example of the observer pattern in Python:
http://en.wikipedia.org/wiki/Observer_pattern
Contrast with this rather standard discussion:
http://www.dofactory.com/Patterns/PatternObserver.aspx#_self1
The difference I am focusing on is that in the latter,
the observer (investor) maintains a reference to the
subject (stock).
(Many questions can be raised of course: see the discussion at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/131499).
Is anything lost by not maintaining this reference (other
than error checking ...)? If I feel the observer needs
access to the subject, what is wrong with just having the
subject pass itself as part of the notification?
Thank you,
Alan Isaac