When our customers create business decision models, they frequently want to have an ability to debug their business rules to understand when and why their rules were executed or skipped. We provided them with the Decision Model Analyzer that partially answers these questions but does it after (!) the model has been already executed. We’ve just completed the development of a new OpenRules Rules Debugger that allows a business user to debug her/his decision models while they are being executed.
Let’s consider how we can debug our popular decision model “Vacation Days” described here. Usually a user clicks on the batch file “build.bat” to build the decision model, and then on “run.bat” to execute it. The model itself is described in the file “settings.bat” that in case of “Vacation Days” looks as below:
Usually the parameter DEBUG is not defined and is assumed to be Off. When you define DEBUG=On and double-click on “run.bat” you will see this protocol at your console:
It will wait for you typing something after “>”. If you just click “Enter” or type “next“, the next rule will be executed and will show:
- the rule and table names
- the rule text
- all variables involved in the rule and their values after the rules execution.
Here is an example:
If you enter “*” or “vars” you will see the values of ALL of your decision variables as below:
If you continue to click “Enter”, you will see all executed rules:
To interrupt the execution process at any moment you may enter the command “>q” or “>quit“.
Let’s start again by double-click on “run.bat”. This time we want to debug only the table “CalculateVacationDays”. To do this, we may enter the command “>table CalculateVacationDays” and then “>go“. The debugger will show all executed rules (without stopping at them) and will stop only before evaluating the table “CalculateVacationDays”. You may display all variables at this moment by typing “>vars“. Here is what you will see:
As you can see, the variables “Eligible for Extra 5 Days”, “Eligible for Extra 3 Days”, and “Eligible for Extra 2 Days” already has been assigned by previous rules to true, false, and false correspondingly. It already can explain you how the rules inside this multi-hit decision tables will be evaluated. However, this is a simple case as our decision table in Excel looks as follows:
Let’s assume that you want to stop before some rule inside this table being evaluated, for example before the second rule described in cells “B6:F6”. You can enter the command “>rule 2” or “>rule B6:F6” or even simply “>rule B6“. After you enter “>go“, you will see:
Now you may click <Enter> and see all actually executed rules or just enter “>go” or “>end“. Here is the final view for this test case:
If you enter the command “>help” you will see a summary of all available commands:
Thus, using these commands you may successfully debug you business decision model. The new Rules Debugger is currently in testing by our beta customers. It will be publicly available as a part of the upcoming release 8.0.1 of OpenRules Decision Manager – the expected release date is Sep. 1.