How to deal with rules that need to be evaluated in a strict order

Quite often you are dealing with the situation when rules need to be evaluated only after the action of the previous rule has been executed, i.e you seem to be dealing with the ordered sequence of rules. However, in Aware IM most rule sequences are un-ordered (except processes that have “Maintain Order” property checked), i.e. Aware IM does not guarantee the order in which rules will be evaluated (see the “Rule Evaluation” section).

One way around this is to use an ordered process, however, this approach is not recommended as the general solution, as the process should not contain any business logic (see What is the difference between processes and business rules?). The better solution is to get rid of the explicit order and break up an ordered rule sequence into a number of independent rules that get triggered when the value of some attribute or list changes. One way to do this is to introduce the “State” attribute to the object. The “first” rule may set the state to some value and the “second” rule can be made dependent on this value. The “second” rule can then set the state to some other value which the “third” rule will check and so on. Note that although we are using the terms “second”, “third” etc, each rule is independent of other rules as it only depends on whether the conditions that it checks are true or false (it does not care who sets the value of the state attribute and when - as long as the state has a particular value the rule will be evaluated). State attribute is often a good solution to the problem, however, any other trigger will do (for example, you can check whether an object has been added to a list) – as long as one rule sets the trigger and another rule checks it, we can express any ordered sequence as an un-ordered collection of independent rules.

  • Last modified: 2022/12/15 05:06