[DUG] Discussion & Donation

Karl at Work karlreynolds at xtra.co.nz
Mon May 15 11:38:23 NZST 2006


>I have implemented the observer pattern previously with the lists
maintained internally by the objects involved, so removing the need to
inherit from a particular class is a great improvement

That is what interfaces were made for.  Create an interface for receiving a
type of broadcast notification, and support it in the object types that you
want to be able to receive such.  Your notifier's lists of different types
of listeners can become a single list of interfaces, and hence your notifier
can broadcast to the interface methods without worrying about what types of
objects it is dealing with, requiring them to inherit from particular
ancestors, or having to do TMethod casts (which provide little flexibility
anyway since target method parameters still have to conform to those of the
broadcaster).

Cheers,
Carl



More information about the Delphi mailing list