text: Q:
  
  will '&&' or ',' "short-circuit" in drools LHS?
  
  I think it is, but I am not very sure.
  for example:
  class Person {
      int age;
      int salary;
      int bonus;
      //getter and setter
  
      public int calcIncome () {
          return salary + bonus;
      }
  }
  
  drl:
  when 
      $p:Person(age > 30, calcIncome() > 1000)
  then
          ...
  
  is it equal to :
      if (person.getAge() > 30 && person.calcIncome() > 1000) {
      ...
      }
  
  so when person's age is not greater than 30, the calcIncome method will not be evaluated?
  thanks!
  
  A:
  
  I did some tests myself, and this is what I found out (at least in version 6.3).
  The alpha sub-network of the RETE algorithm for a particular rule in Drools is always evaluated in sequence. The order of the nodes appears to be the order the constraints have in the pattern they belong to. So, we could say that there is an implicit short-circuit mechanism going on.
  By the way, I didn't find any difference between the usage of a comma ',' or ampersands '&&'. In both cases, Drools treated the expressions as 2 separated alpha nodes.
  This is what I did:
  
  Model
  public class Person {
      private int age;
      private int salary;
      private int bonus;
  
      public Person(int age, int salary, int bonus) {
          //set values
      }
  
      public int calcIncome() {
          throw new IllegalStateException("Expected error here!");
      }
  
      //getters
  }
  
  Note how I'm deliberately throwing an exception in calcIncome().
  
  Rule A
  This rules uses '&&' to indicate an AND operation between 2 constraints on a Person pattern.
  Again, I got the same results by using comma instead of the ampersands.
  DRL
  rule "Rule A"
  when
      $p:Person(age > 30 && calcIncome() > 1000)
  then
      System.out.println("Rule A");
  end
  
  RETE Network
  The Rete network for the precedent rule looks like this:
  
  In the image above we can see the 2 different alpha nodes (yellow). Because alpha nodes are evaluated in sequence, the second node will only be evaluated, in this case, if the Person we are evaluating has more than 30 years.
  Tests using Person instances with more and less than 30 years corroborated this: instances with more than 30 years thrown the exception from calcIncome().
  
  Rule B
  Then, I was curious on what happen when we use and or (||) operator instead of an and.
  DRL
  rule "Rule B"
  when
      $p:Person(age > 30 || calcIncome() > 1000)
  then
      System.out.println("Rule B");
  end
  
  RETE Network
  Interestingly enough, the RETE network for this example resolves the OR operator inside a single alpha node.
  
  Whatever mechanism Drools is internally using (I guess is MVEL) to resolve this node seems to have a logical short-circuit implemented. The tests I did shown that the expected exception was only thrown when Person instances with less than 30 years were used.
  
  Final Note
  Even if Drools seems to short-circuit when dealing with constraints inside a single Pattern, things are different when rules contain multiple patterns. 
  According to my tests, all the constraints of a single pattern will be resolved using a short-circuit enabled algorithm. This mainly relies in the fact that alpha nodes in the Rete network are evaluated in sequence. 
  Now, when dealing with multiple patterns in a rule, the evaluation order  can't be predicted in compilation time. Each pattern in a rule could be independently evaluated according to how the particular Rete network looks for the particular case. 
  Hope it helps,
  
  