The Filters section of a Rulesheet can contain one or more master conditional expressions for that Rulesheet. In other words, other business rules fire if and only if data survives the Filter, and shares the same scope as the rules. Using the air cargo example from the previous chapter, model the following rule:

Figure 1. Rulesheet using a filter and nonconditional rule

Here, the value of an aircraft's maxCargoWeight attribute is assigned by column 0 in the Conditions/Actions pane (what is sometimes called a nonconditional or action-only rule because it has no conditions). The filter acts as a master conditional expression because only aircraft that satisfy the filter. In other words, only those aircraft of aircraftType = '747', successfully “pass through” to be evaluated by rule column 0, and are assigned a maxCargoWeight of 200000. This effectively filters out all non-747 aircraft from evaluation by rule column 0.

If this filter were not present, all Aircraft, regardless of aircraftType, would be assigned a maxCargoWeight of 200000 kilograms. Using this method, additional Rulesheets can be used to assign different maxCargoWeight values for each aircraftType. The Filters section can be thought of as a convenient way to quickly add the same conditional expression or constraint to all other rules in the same Rulesheet.

You can also achieve the same results without using filters. The following figure shows how you use a Condition/Action rule to duplicate the results of the previous Rulesheet. The rule is restated as an if/then type of statement: if the aircraftType is 747, then maxCargoWeight equals 200000 kilograms.

Figure 2. Rulesheet using a conditional rule

Regardless of how you choose to express logically equivalent rules in a Rulesheet, the results will be equivalent. While the logical result may be identical, the time required to produce those results may not be. See How to optimize Rulesheets for information about compression techniques that remove redundancies.

There may be times when it is advantageous to choose one way of expressing a rule over another, at least in terms of the visual layout, organization, and maintenance of the business rules and Rulesheets. The example discussed in the preceding paragraphs was very simple because only one action was taken as a result of the filter or condition. In cases where there are multiple actions that depend on the evaluation of one or more conditions, it may make the most sense to use the Filters section. Conversely, there may be times when using a condition makes the most sense, such as the case where there are numerous values for the condition that each require a different action or set of actions as a result. In the preceding example, there are different types of aircraft in the company's fleet, and each has a different maxCargoWeight value assigned to it by rules. This could easily be expressed on one Rulesheet by using a single row in the Conditions section. It would require many Rulesheets to express these same rules using the Filters section.