Let's say we have a bunch of user defined formulas that depend on other formulas that look something like this (this could be any syntax).
Example: Give a Customer with multiple accounts
ExampleOne: Accounts.Sum() - ExampleTwo
ExampleTwo: Accounts.CurrentAssets - 200 / CurrentYear
...etc
I want to design a service that given a customer with accounts, evaluate these formulas and return the result for each formula item:
ExampleOne: 123
ExampleTwo: 999
...etc
What is the best approach about this given the following requirements within the c# .net environment. Please note that how the syntax would be is not important here):
- These formulas will be frequently changed by non technical people
- There are hundreds of these formulas that have depenedencies on each other (Acyclic)
- These formulas need to be stored in database
- Calculations performed to evaluate these formulas must be fast
I am trying to evaluate several options:
Graph Database
Parsing the formulas as an abstract Syntax Tree and storing them into a graph database. However, with this approach, it seems difficult to update formulas after creation.
Evaluate formulas as runtime
I could write a parser that would take a formula and evaluate it at runtime.
Rules Engine
I saw this similar question. But I'm not sure if this is the right approach for this.
Relational Database
How would I model formulas in the database with the flexibility of easily changing them?
Aucun commentaire:
Enregistrer un commentaire