Tuesday, 20 January 2015

Backward chaining in Pega

Backward chaining executes declare expression rules when a value is needed for a property, as opposed to when inputs change. For example, a value may be needed because a property’s value is referenced in an HTML stream for display.
Backward chaining applies to declare expressions rules with the Calculate Value field set to one of the following:
  • When used if no value present
  • When used, if property is missing
  • Whenever used
Think of it like this … the system says “I need property X, if it isn’t there, calculate it for me”.
For example: Area = Length x Width and is set up for backward chaining with the “Whenever used” option set on the Area property.  If you try to display Area (even just in the property rule preview), the declare expression rule re-computes. This re-computation is driven by the use or referencing of Area, not by any changes in Length or Width.
If a value for Area is needed through backward chaining, but Length has no value, the chaining may continue using a declare expression rule to calculate Length, and so on.  Alternatively, the application can prompt a user to enter a value.
Experiment with backward chaining using the following standard rules
  • Work-.VerifyProperty flow action
  • Work-.VerifyPropertywithListing flow action
  • Work-.PromptGoalSeekProperty HTML rule
  • Work-.VerifyProperty activity
The Property-Seek-Value method is the foundation of backward-chained processing. What is really important to understand is that the system will only execute the required calculations as needed, which can result in huge efficiency gains
Let’s look at the conditional display of a Volume property.  If the Volume property is displayed, the expression for the calculation of its value fires – backward chaining.
If the harness does not display Volume (set by a When rule), calculation is not necessary and valuable system resources are saved as a result.
Just imagine if the retrieval and calculation processing of this data had a cost, either literally or just in terms of time and system resources.  With a procedural design model you would have to either code a lot of if/else statements to micro manage things, or waste valuable time and money processing data needlessly.
For more information on backward chaining, refer to PDN and Developer Help topics on Locate Pages, Locate Activities and Declare Pages, as well as the e-Learning course on Declarative Pages

No comments:

Post a Comment