Multiple Rule Variables – BAL vs IRL

The way multiple rule variables are declared and instantiated in working memory varies between the BAL and IRL.

BAL:

Suppose if we assign ‘Customer’ class instance to a multiple variables using definitions of a rule they are treated as two different instances.

definitions
set ‘customer1’ to Customer;
set ‘customer2’ to Customer;

Here customer1 and customer2 are treated as two different instances of class Customer and can be acted on independently.

IRL:

If we consider the same example as above and define multiple variables in IRL as below:

when {
customer1: carrental.Customer();
customer2: carrental.Customer();
} then {

}

Here the variables customer1 and customer2 will refer to the same Customer instance in working memory and may create conflicts.To ensure it refers to different instances we need to add a test as below:

when {
customer1: carrental.Customer();
customer2: carrental.Customer(?this != customer1);
} then {

}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s