I am thinking of an object structure that will perform complex calculations. Calculations are performed based on entries in the graphical user interface.
The form is as follows:
A = B+C; B = D*E; C = C; (simply value insert by the user) D = C/E; E = C*C;
The user can enter values for all values (from A to E / in a real project, there are about 210 variables). If it is impossible to develop a mathematical formula for calculating other values, this will be done by iterating over the values until you find the “working setting”.
Now I think of the following structure: Each variable is an object of a data class. Each dataclass can register a listener with other dataclasses to receive value change events. If a dataclass receives a value change event, it recounts itself and informs all listeners about this own datachange.
The problem is this: If the last calculation in this chain gets the result, then the entered value is impossible (for example, "division by zero"), it will set the value to the nearest possible value (in this case 1). Then all the calculations in the chain before this should be performed again in the reverse order.
Is there a better structure in your eyes than this listener-based structure, where everyone recounts if he detects an event of a change in the observed variables (with 210 veriables I'm going to lose sight, which calculates what, when and why: The central calculation structure seems to be is more convenient for me, but I can’t imagine a good structure for a central computing unit).
Any opinions and recommendations are welcome! Hooray, Joan
source share