jamoma / JamomaCore

Jamoma Frameworks for Audio and Control Structure
Other
36 stars 14 forks source link

Review the design pattern for parent class attribute update notifications #354

Closed tap closed 8 years ago

tap commented 9 years ago

Currently, e.g.

  1. MaxNumChannels attribute is changed
  2. Some stuff happens in TTAudioObject (where the attribute is defined with a custom setter)
  3. This method then sends a message to self, the 'update', to notify the child class of the change

This is also true for SampleRate but not for bypass or mute. Why?

Two alternative approaches:

  1. Also define virtual methods for the update, and then call those. If the subclass overrides it then it gets the notification and the cost is less (and we don't have to bind additional stuff in the ctor)
  2. If a subclass wants to know when an attribute has changed, why doesn't it just subscribe to the attribute for notifications? This approach is more generalized and works without having to add extra plumbing for every attribute or remember to cascade the update is there is a big tree of subclasses.
tap commented 8 years ago

Now tracked as jamoma/jamoma2#11