what a good approach to ensure that a fact is only inserted once, kind of like a primary key in a DB?
I could have a rule where the RHS literally checks in a DB to see if the key is there, but it seems better to keep as much state as possible in the session?
It seems kind of dangerous have side-effects inside of a rule.
What would be the best practice to implement a decision table like that?
At my team a couple of product specialists use Excel for logic like that and I was wondering if I can somehow turn them into Clara rules and use it to make decisions. Has anyone have done something similar in the past?
@schmee Use an accumulator for the fact you actually want 1 of
if you have rules that may produce multiples
make an intermediate fact type to represent the multiple
then a single acumulator to aggregate it “down to 1”
this aggregation rule is you explicitly choosing how you want to represent or handle multiple supporting matches
it’s not always obvious actually - if they happen to have different data associated with them them or something
gotcha, thanks for the tip!
@nikola.kasev I haven’t attempted anything first-class with tables like that - but you could start by just trying to make rule to represent it and see what patterns may emerge
I know some traditional rete-based engines - like Drools on the JVM - had some spreadsheet-like decision table functionality built on top to capture the pattern - but underneath was stilll just plain rules