comp.lang.ada
 help / color / mirror / Atom feed
From: "Russ McClelland" <russmc@netbox.com>
Subject: Re: Conception problem
Date: 1997/05/30
Date: 1997-05-30T00:00:00+00:00	[thread overview]
Message-ID: <01bc6d0b$c8551be0$3c04109b@russ-mc-760ed> (raw)
In-Reply-To: 01bc6c26$4e1c0ef0$ab526478@jims_nt_1


> Nicolas Gautier <GautierN@sofreavia.fr> wrote in article
> <01bc6b91$54b26a60$d19ecec2@beta>...
> > Hello,
> > Sorry if this mail is a little bit long. This is a question about what
is
> > the best 
> > way to handle lists where modifications of one element can trigger
> > modifications
> > on other elements of the list.
> > 

> Jim shaw <James_P_Shaw@msn.com> wrote in article
<01bc6c26$4e1c0ef0$ab526478@jims_nt_1>...
> A better solution would be to implement the Observer design pattern
(Design
> Patterns, by Gamma et.al.). Just a quick blurb on this pattern (please
see
> book for more detail):
> 
> Essentially all objects of class type B, would keep a list of
"subscribed"
> objects to notify when an event of interest occurs. When a particular
event
> (of your own choosing) occurs, the object simply "notifies" all
subscribed
> objects of this event (i.e. send a message to that object).

As a refinement, I would have the class only hold a collection of
dependents.  The class generates the event and lets each dependent decide
whether or not they are interested in the dependent.  This helps separate
the class from the dependents and puts the decision in the observers.

If you are using VW, this is already available.  The "event" isn't really
an event object but pieces of information that are passed to the observers
like the aspect that changed, the new value etc.  One could probably extend
this easily to support real event classes.

Another idea would be to have the observer register as a dependent of the
specific event classes.  Whenever the event class created a new instance,
it would notify all the registered observers.

The difference between the two strategies is this:

S1.  The observers are interested in changes only to a specific instance.
S2.  The observers are interested in events at a system level, regardless
of a specific instance.


-- 
Persistence is futile.
You will be aggregated...






  reply	other threads:[~1997-05-30  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-28  0:00 Conception problem Nicolas Gautier
1997-05-29  0:00 ` John Heidelberger
1997-05-30  0:00 ` Jim shaw
1997-05-30  0:00   ` Russ McClelland [this message]
1997-06-03  0:00   ` Malcolm Macgregor
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox