3 ms·
Where I have needed things like this before it is generally that there is a finite list of functions with some intersection of arguments, and the classification
by netcraft 3y ago
Where I have needed things like this before it is generally that there is a finite list of functions with some intersection of arguments, and the classification of which function (strategy) you need is what goes in the DB and the code lives in, well, the code. That way its unit testable, version controlled, and way better understandable. If it has to happen in SQL (which I def dont have a problem with personally), then its a case statement - but still, it lives in code, not in the DB.
I def wouldnt want anyone editing formulas in a crud screen, they should be picking from available options.
If your options are too varied to support this though, I dunno, maybe you need to get more creative - but balancing that with needing to know that what gets set is correct and valid seems challenging. No way im doing this with something that is calculating payments!