I have an application I'm working on and it has several pieces of data that are interdependent. Basically, I have a set of numeric fields that are used to compute other numeric fields, which are then used to compute other fields. I am trying to determine the best way to handle a potentially large number of changes.
One solution that I was thinking about is that I can override the settings for the values that the user can change to perform calculations, and then update the other values in the data object accordingly. The biggest drawback is the simple (somewhat boilerplate) code that needs to be written.
Another solution that I was thinking about is to use key value observation to process data changes and then update the dependent values from those changes. Note that none of the dependent values will ever be updated, unless the independent value changes. Although I think it will be a little more elegant, I am concerned about potential performance issues or issues that I may not consider.
Is there a third way that I am missing? Are there any best practices for this kind of work? I know that I will probably have to write a bunch of template code - I would like the code to be the easiest to maintain and the least amount of code.
source
share