Propagating change in object graph

  • Hi the list,
    I have a quite generic question about how to propagate changes in a Cocoa
    app. I have used some different paradigms for this, each with different
    pros/cons. I would be interested in getting some thoughts about this, what
    are your established way of doing it...

    Think of it as a view that needs to redisplay itself when properties of an
    object deep in the graph change.

    1. Use NSNotificationCenter, pass the object, etc. (cons: notification is
    sent to all observer, across documents...)
    2. Use KVO (seems complicated when a deep object is part of a to N relation)
    3. Send message up in the graph : point -> curve -> drawing -> document,
    (requires back pointers + specific methods)

    Thanks for sharing,

    Raphael
  • On Sep 6, 2007, at 1:00 AM, Raphael Sebbe wrote:

    > Hi the list,
    > I have a quite generic question about how to propagate changes in a
    > Cocoa
    > app. I have used some different paradigms for this, each with
    > different
    > pros/cons. I would be interested in getting some thoughts about
    > this, what
    > are your established way of doing it...
    >
    > Think of it as a view that needs to redisplay itself when
    > properties of an
    > object deep in the graph change.
    >
    > 1. Use NSNotificationCenter, pass the object, etc. (cons:
    > notification is
    > sent to all observer, across documents...)
    > 2. Use KVO (seems complicated when a deep object is part of a to N
    > relation)
    > 3. Send message up in the graph : point -> curve -> drawing ->
    > document,
    > (requires back pointers + specific methods)
    >
    > Thanks for sharing,

    You can create your own notifications centers if you want to scope
    who is observing what.

    -Shawn
  • hmm... seems good ;-)

    Raphael

    On 9/6/07, Shawn Erickson <shawnce...> wrote:
    >
    > On Sep 6, 2007, at 1:00 AM, Raphael Sebbe wrote:
    >
    >> Hi the list,
    >> I have a quite generic question about how to propagate changes in a
    >> Cocoa
    >> app. I have used some different paradigms for this, each with
    >> different
    >> pros/cons. I would be interested in getting some thoughts about
    >> this, what
    >> are your established way of doing it...
    >>
    >> Think of it as a view that needs to redisplay itself when
    >> properties of an
    >> object deep in the graph change.
    >>
    >> 1. Use NSNotificationCenter, pass the object, etc. (cons:
    >> notification is
    >> sent to all observer, across documents...)
    >> 2. Use KVO (seems complicated when a deep object is part of a to N
    >> relation)
    >> 3. Send message up in the graph : point -> curve -> drawing ->
    >> document,
    >> (requires back pointers + specific methods)
    >>
    >> Thanks for sharing,
    >
    > You can create your own notifications centers if you want to scope
    > who is observing what.
    >
    > -Shawn
    >
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today