Re: Generalized "observer" pattern
On 2007-09-24 00:17, Gianni Mariani wrote:
Two issues here:
a) What is the accepted definition of "observer pattern". While I can't
point to anything specific, I do remember having issues with
inconsistency in the definition.
I would assume that it is the one given in the GoF book, if you do not
have it the wikipedia article is more or less a copy from the book,
especially the "Participant classes" section.
b) Generic observer design in C++. I have been pushing the Austria
"Twin" interface for a while and more recently the multi threaded
version of it "TwinMT" (see the 6129 alpha on sourceforge)
I am trying to distill the "fundamental" hard problems in software
development, especially regarding C++ and I've seen too many issues
relating to the observer pattern I think it is elevated to "fundamental".
I do not see how there can any issues with the observer pattern, it is
very simple, however I perhaps not very useful either. I prefer a more
advanced version (I am sure this is some pattern but I do not know its
name) where the observing class is not only informed that something has
happened, but also what. So instead of just having a notify() function
the observing class has a onFoo(Bar& sender, FooArgs arguments) function
that tells the observing class what happened (the arguments) and to whom
(the sender). Anyone know the name of this pattern?
--
Erik Wikstr??m