Pattern for object modified

V

VisionSet

What is the best approach to take in order to fire an event that signifies
that an object has been modified.
This needs to be appropriate for objects with deep trees, where any child
object being modified will fire the event.

TIA
 
T

Thomas Weidenfeller

VisionSet said:
What is the best approach to take in order to fire an event that signifies
that an object has been modified.
This needs to be appropriate for objects with deep trees, where any child
object being modified will fire the event.

The very best way is not to observe individual nodes at all. Reordering
a tree might result in a huge amount of fired events, depending on the
type of events you want to have. Instead, let the tree itself be monitored.

The second best way is to at last avoid the situation where each node in
the tree has its own list of event listeners. Depending on your
situation, it might be enough to have a single list for the whole tree,
and provide the changed node (or some node id) as an actual parameter
when an event is fired. If you need multiple - but not to many -
sets/groups of event listeners, consider to use the flyweight design
pattern to avoid having to duplicate the groups for each associated node.

/Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top