"Jocke" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed)...
> I'm working on an application where some common objects are consumed
> thorough the application. The issue is that such a common object - say
some
> kind of graphics object - shall be replaced by another object now and
then,
> and then all references should be updated at once. Say I reference the
same
> graphics object ten different places in the application. How can I create
a
> new graphics object and then make all of the ten references point to this
> new object?
>
> Well, I know I could do this by calling a GetNewestGraphicsObject() method
> instead of having references directly to the commonly used obejcts. Then
> this intermediate method returns the newest object. But is there a way to
> achieve this without using methods?
Take a look at the Observer pattern. The Subject object can change state and
any other objects that are Observers of that Subject will be notified when
the change occurs. The idea of a multicast delegate as used in .NET events
fulfils this pattern perfectly.
Joanna
--
Joanna Carter
Consultant Software Engineer