I am working on an application that is essentially a calculator, not the handheld calculator but more of a spreadsheet. It will take many inputs across different views and show the outputs all over the place.
The application will be running many calculations. These calculations depend mostly on user given inputs but it can also depend on the results of other calculations.
Another requirement is that the calculations offered to the user can be edited in a CMS style. This means that when the application starts, it will load the calculations and its necessary inputs from a file called calculations content.
The outputs should always be up to date, meaning that if a user updates a value, then the calculations that depend on this input should run again, sending the output to its dependent calculations and so on.
So far, I've conceived a directed graph of calculations in which parent-children relationship represent the input and its dependent calculations. This way, the process that executes a calculation will be able to check if it has any dependants and run them.
The problem with this pattern is that it can lead to duplicated calculations. If an input A has two dependants B and C and a calculation D depends on both B and C, then when A is updated, D and its dependants will run two times.
It might be worth knowing that the application is built with a Redux architecture on Javascript.