0% found this document useful (0 votes)
26 views20 pages

Declarative Rules

The document discusses different types of declarative rules in PRPC including declare expressions, constraints, declare trigger, and declare onchange rules. It provides examples of how to write declarative rules and explains how the system handles declarative rules differently than procedural rules.

Uploaded by

hc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views20 pages

Declarative Rules

The document discusses different types of declarative rules in PRPC including declare expressions, constraints, declare trigger, and declare onchange rules. It provides examples of how to write declarative rules and explains how the system handles declarative rules differently than procedural rules.

Uploaded by

hc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

MATERIAL FOR PRPC CERTIFICATION

Declarative Rules

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


Declarative Rules % of EXAM - 5%

What Is a Declarative Rule?

• Allow for dynamic processing of property values


• Do not need to be explicitly called
• Are not run in a sequential fashion
• Defines system “global truths”– what is always true
• Creates a “dependency network” of related property values
• System manages re-evaluation when it detects change
• We have to use declaratives when you want to maintain
relationships between data
• For example:
• Create a Declare Expressions rule instead of using a Property-Set
method in an activity.
• Use a Constraints rule instead of a field validation rule.
• As far as PRPC is concerned one of the guardrail says that calculate
and edit declaratively, not procedurally.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL
2
Declarative Rules % of EXAM - 5%

• Don’t follow this approach i.e by using property-set in an activity.

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


3
Declarative Rules % of EXAM - 5%

• Look-N-Feel of a Declarative Rule (Follow this approach for calculations)

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


4
Declarative Rules % of EXAM - 5%

Forward Chaining Mechanism in Declarative Rules

Enter all possibly required data and calculate rule results in


sequential order

Declarative network Values at runtime

OrderTotal 123.22
Forward chaining

OrderPrice (All items) Tax


17.5% 104.87

ExtendedPrice Single Item


54.95 49.92

Quantity Price
5 X 10.99 4 X 12.48

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


5
Declarative Rules % of EXAM - 5%

Backward Chaining Mechanism in Declarative Rules

Process Commander allows computation to advance even when


the value of an input or parameter property is not available

Backward chaining OrderTotal

OrderPrice TAX

ExtendedPrice

Quantity Price

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


6
Declarative Rules % of EXAM - 5%

Dependency Network Analysis (Finding the DNA) [ This shows us which one is
dependent on which ]

Top-level declarative
expressions displayed on
the desktop, sorted by class
for easy access
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL
7
Declarative Rules % of EXAM - 5%

How to use Declarative Rule Inspector?

Declarative network analyzer Based on selected rule,


graphically displays rule system prompts for data
dependencies to test the rule

Rules Inspector highlights


and provides anchors to Easily test varying
retrieve declarative rules inputs to test rules and
conduct what-if analysis
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL
8
Declarative Rules % of EXAM - 5%

Declarative Rules Types

• Four main types:


• Declare Expressions
• Constraints
• Declare Trigger
• Declare OnChange

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


9
Declarative Rules % of EXAM - 5%

How to write Declare Expression?

Expression
Builder

Browse
library
functions
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL
10
Declarative Rules % of EXAM - 5%

What are Constraints?

• Provide bounds on the value that a property can hold. For


example:
• Property cannot be negative
• Property cannot be greater than a certain value
• Can target more than one property in a single constraints rule

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


11
Declarative Rules % of EXAM - 5%

Condition
• How to write Constraints? type

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


12
Declarative Rules % of EXAM - 5%

• A declarative rule describes a computational relationship among


property values that is expected to be valid "always" or "often" or
"as needed". Declarative rules will be in force automatically and
hence you need not call these rules explicitly

• Declarative rules need / should not be refereed from any rule. They
are always in force. The primary benefit of declarative processing is
that the system, rather than the developer, controls when
computations are processed

• There are five types of declarative rules


• Constraints rules (Rule-Declare-Constraints rule type)
• Declare Expression rules (Rule-Declare-Expressions rule type)
• Declare Index rules (Rule-Declare-Index rule type)
• Declare OnChange rules (Rule-Declare-OnChange rule type)
• Declare Trigger rules (Rule-Declare-Trigger rule types)
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL
13
Declarative Rules % of EXAM - 5%

• Rule-Declare-Expressions : R-D-E ( Rule-Declare-Expressions ) can be created for


properties and will have typically same name of the property. R-D-E facilitates
automatic computation of the property value, basing on changes of other property
values. For example, we can declare a R-D-E for property called “Area” , so that
whenever it’s value is accessed from clipboard, it’s value is equal to the product of
properties, Length and Width. Once the R-D-E is saved for the property “Area”, any
change to a Length or Width value, regardless of how it occurs, causes an immediate
recomputation of the value of the Area property. For example following is the R-D-E
created for gross salary property

• Idea is, Whenever value of any property from Basic, HRA, SpecialAllowance, ITax and
PTax is changed, The value of GrossSalary in clipboard automatically changes. For
example, if an activity which has Property-Set method for property “Basic” and if this
activity is executed, the clipboard value of GrossSalary automatically changes

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


14
Declarative Rules % of EXAM - 5%

• Declarative rules are not referenced explicitly in other rules. If you


use of an property that is referenced in the declarative rule, it
automatically causes the declarative rule to run.

• Forward Chaining : Forward chaining provides the automatic


calculation of the property by executing the declarative rule, when
any one of the input property value is changed. For example, if the
Area property depends on the Length and Width property, then
forward chaining causes the Area property to be recomputed each
time either Length, or Width value changes

• Backword Chaining : Forward chaining provides the automatic


calculation of the property by executing the declarative rule, when
a value is needed for a property, rather than when inputs change.
For example, if the Area property depends on the Length and Width
property, then backword chaining causes the Area property to be
recomputed each time the Area property is required/ referred
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL
15
Declarative Rules % of EXAM - 5%

• What decides the forward chaining / Backword chaining ? : The


“Target Property Data “ field in declare expressions decide this:

Whenever inputs change – Forward Chaining


When used, if no value present – Backword Chaining
When used, if Property is missing – Backword Chaining
Whenever used – Backword Chaining

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


16
Declarative Rules % of EXAM - 5%

• Rule-Declare-Constraints : Constraints rules can provide an


automatic form of property validation every time the property's value
is "touched", in addition to the validation provided by the property
rule or other means. The system evaluates constraints automatically
each time a property identified in a Constraints rule is changed. This
technique is known as forward chaining. Constraints use the forward
chaining. For example we can create a constraint for multiple
properties to see that all amount are positive

• Same as Declare expressions, we can also declare constraints for the


properties inside the embedded page. In that case, we need to
specify the page name and it’s class in the pages and classes tab

• Rule-Declare-Index : Declare Index rule are defined for defining


criteria under which Process Commander automatically maintains
index instances for faster access.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL
17
Declarative Rules % of EXAM - 5%

• Rule-Declare-OnChange : Declare OnChange rules can be used to


run an activity automatically at activity step boundaries whenever
the value of a specified property changes. This capability provides a
form of automatic forward chaining. If you specify more than one
property, they all must be on same page. For example, we can
create a declare onchange to call an activity that send a mail to
employee when ever either HRA or Basic or SpecialAllowance are
changed.
• Same as Declare expressions, we can define declare OnChange rules
for the properties inside the embedded page. In that case, we need
to specify the page name and it’s class in the pages and classes tab.

• Rule-Declare-Trigger: A trigger rule identifies an activity that runs


automatically whenever an object of a particular class is saved in or
deleted or updated from the database.

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


18
Declarative Rules % of EXAM - 5%

• Triggers implements forward chaining


• Almost all the declarative rules implement only the forward
chaining, except the R-D-E. In R-D-E, we have a choice to decide
either we should go to forward chaining or backward chaining

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


19
Q&A

????

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL


20

You might also like