Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8988391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:00:18+00:00 2026-06-15T22:00:18+00:00

when writing drools rules, do I separate the checkings into more rules or group

  • 0

when writing drools rules, do I separate the checkings into more rules or group them all in one rule to have more ifs in the ‘then’ part? Not considering any management issues, just performance (e.g. execution time, memory usuage).

Say I have multiple tasks that their conditions and stuff-to-do are 90% similar, just 10% left are specific to each of them. Do you write

rule A
when (90% conditions) and (task 1 or task 2 or task n)
then
    if (10% conditions for task 1) ...(10% stuff-to-do for task 1)
    else if (10% conditions for task 2) ...(10% stuff-to-do for task 2)
    else if (10% conditions for task n) ...(10% stuff-to-do for task n)
    (90% common stuff-to-do)
end

or

rule B-1
when (90% conditions) and (10% conditions for task 1)
then
    (90% common stuff-to-do) + (10% stuff-to-do for task 1)
end
rule B-2
when (90% conditions) and (10% conditions for task 2)
then
    (90% common stuff-to-do) + (10% stuff-to-do for task 2)
end
rule B-n
when (90% conditions) and (10% conditions for task n)
then
    (90% common stuff-to-do) + (10% stuff-to-do for task n)
end

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:00:19+00:00Added an answer on June 15, 2026 at 10:00 pm

    Instead of grouping the conditions and tasks together, you need to separate them into individual rules, like in the following example. Execution time will not matter much, thanks to RETE and memory usage mostly depends on your facts, not rules.

    By separating your conditional logic into separate rules, you will gain testable and manageable code base. Putting everything into a big rule is not much different from using if-else statements in plain java code, in that case Drools will just add complexity to your project without any benefits.

    rule 90_1
    when
        //first rule for common stuff
    then
        //
    end
    
    
    rule 90_2
    when
        //second rule for common stuff
    then
        //
    end
    
    
    rule 90_N
    when
        //last rule for common stuff
    then
        //
    end
    
    rule A_1
    when
        //first rule for A
    then
        //
    end
    
    
    rule A_2
    when
        //second rule for a
    then
        //
    end
    
    rule B
    when
        //rule for B
    then
        //
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is Drools suitable for writing rules for Stemming and/or POS tagging ? Suggestions for
I'm writing a presentation about rule engine technology, specifically JBoss Drools. What are some
Writing a file utility to strip out all non-ASCII characters from files. I have
I have a problem in using Drools Planner (written in Java) in Scala. One
Writing Classic ASP code in JScript has a lot going for it: more humane
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
Writing a recursive function, I want one fn that executes when the list has
Writing/reading code seems less stress then preparing a deploy scripts such as ./configure then
Writing an iPhone app in Objective-C, I have a date in string form (in
Writing a lexer of .java source files in Java. I have a stream of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.