An application I’m working requires complex parametrisation and configuration in order to model custom parts. There are various interdependencies between different parameters, such as that setting parameter ‘A’ invalidates certain values for ‘B’ and ‘C’, or adds additional constraints for values of parameter ‘D’.
Currently, this is solved by storing all parameters in look up tables, and running rules on them. The rules are hand-written in XML, are loaded and converted to some intermediary format, which is used for the rule engine. Every time a parameter changes, all the rules are rerun.
This is at the same time very slow and error-prone.
I feel that it might be beneficial to use a (DAG) based approach, where we can do updates only on subsets of the graph.
Is this a good idea? Do you know any better approaches? If you have experience with similar problems, how did you solve them?
Edit: I am trying to achieve a design where only dependent subsets of a parameter have to be updated on a change. Currently, the rules are rerun globally on every single change. The parameters are set to defaults, but can be changed by the user. Depending on the value of a parameter, the defaults for others might be different.
Yes. You can create DAG and do a DFS traversal and figure out the dependency chain.
From what I’ve understood, there is a complex dependency structure which can be modeled by DAG. If any one changes, the dependent components needs to be changed. Compiles have been doing this for years. You might want to look into dependency analysis done by them.
Another approach can be modeled by Observer pattern. Here each object exposes a way to notify observers if anything has changed. Dependent objects subscribe to notifications. When an event occurs which changes object state, it calls the dependent listeners.