Order independence does not apply to conditional expressions that include collection operations. In the following Rulesheets, notice that one of the conditional expressions uses the collection operator ->size, and therefore must use an alias to represent the collection Person.

Figure 1. Collection operator in Condition row
Figure 2. Collection operator in Filter row

The Rulesheets appear identical with the exception of the location of the two conditional statements. But, do they produce identical results? Let's test the Rulesheets to see, testing Collection operator in Condition row first:

Figure 3. Ruletest with three skydivers

What happened here? Because filters are always applied first, the Rulesheet initially filtered out the elements of collection person whose skydiver value was false. Think of the filter as allowing only skydivers to pass through to the rest of the Rulesheet. The Conditional rule then checks to see if the number of elements in collection person is more than 3. If it is, then all person elements in the collection that pass through the filter (in other words, all skydivers) receive a riskRating value of high. Because the first Ruletest included only 3 skydivers, the collection fails the conditional rule, and no value is assigned to riskRating for any of the elements, skydiver or not.

Now modify the Ruletest and rerun the rules:

Figure 4. Ruletest with four skydivers

It is clear from this run that the rules fired correctly, and assigned a riskRating of high to all skydivers for a collection containing more than three skydivers.

Now, test the Rulesheet in Collection Operator in Filter row, where the rule containing the collection operation is in the Filters section.

Figure 5. Ruletest2 with three skydivers

What happened this time? Because filters apply first, the ->size operator counted the number of elements in the person collection, regardless of who skydives and who does not. Here, the filter allows any collection – and the whole collection – of more than three persons to pass through to the Conditions section of the Rulesheet. Then, the conditional rule checks to see if any of the elements in collection person skydive. Each person who skydives receives a riskRating value of high. Even though the Ruletest included only three skydivers, the collection contains four persons, and, therefore, passes the Preconditional filter. Any skydiver in the collection has its riskRating assigned a value of high.

It is important to point out that the Rulesheets in Collection Operator in Condition row and Collection Operator in Filter row implement two different business rules. When the Rulesheets were built, the plain-language business rule statements violated the methodology!). The rule statements for these two Rulesheets would look like this:

The difference is subtle but important. In the first rule statement, the test is for skydivers within groups that contain more than three skydivers. In the second, the test is for skydivers within groups of more than three people.