Pattern for object modified

Discussion in 'Java' started by VisionSet, Jun 13, 2004.

  1. VisionSet

    VisionSet Guest

    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
    --
    Mike W
     
    VisionSet, Jun 13, 2004
    #1
    1. Advertising

  2. VisionSet wrote:
    > 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
     
    Thomas Weidenfeller, Jun 14, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    17
    Views:
    1,917
    Chris Uppal
    Nov 16, 2005
  2. sunny
    Replies:
    1
    Views:
    476
    Salt_Peter
    Dec 7, 2006
  3. Pallav singh
    Replies:
    0
    Views:
    392
    Pallav singh
    Jan 22, 2012
  4. Paul Murton
    Replies:
    7
    Views:
    123
    Logan Capaldo
    Aug 28, 2006
  5. Ben Sizer
    Replies:
    11
    Views:
    235
    Steven D'Aprano
    Mar 8, 2013
Loading...

Share This Page