3

My current application has a number of rules in the form of if-else conditional statements that work on some parameters to either modify some set of variables or set/unset other variables. Due the increasing clients that we are having, the application code is now getting cluttered with these if-else rules. Also, these rules are not static they change quite frequently tweaked, some are made to expire other's activated etc. I have seen that drools etc based on JSR094 provide this functionality to separate logic/rules from application source code.

My requirement is not so complex, I don't need complex rule visualization software, editing UI, etc. but definitely dynamic(modifications/editable rules), also my requirement requires low latency as it processes some 100s of million requests a day.

Any ideas of a light weight implementation to solve this as I feel drools is overkill?

My platform for development is Java. Example rule:

if ( age > 15 && item belongs_to(footwear) || using(mobile_device) ) 
        discount = 2%
Ryan B
  • 3,364
  • 21
  • 35
hershey92
  • 783
  • 2
  • 6
  • 17
  • 1
    Drools would fit perfect in implementing this. – Konstantin Yovkov Jul 15 '14 at 12:48
  • 2
    So you're saying you want the advantages of a rules engine, but you wouldn't want to use a rules engine... The only end result is going to be you implementing your own one, and that's probably not optimal. – Kayaman Jul 15 '14 at 12:52

1 Answers1

0

I strongly suggest you use a proper rule engine, drools, flexrule... If you do not like using those solution, you always can find some expression evaluation libraries that let you to parse and execution a string based expression.

Arash Aghlara
  • 330
  • 3
  • 11
  • 1
    is there a list of major companies that use drools in production like twitter, facebook etc ? Any white papers that describe how it scales/performance with more rules and dynamism ( edits to rules ) ? – hershey92 Jul 16 '14 at 11:54
  • I am not aware of such a list, when there is a complex business domain e.g. healthcare, inventory, finance or a system that requires to be compliant with regulations then business rule approach make sense. Or the other usage can be making a system flexible to change, i.e. more configurable and adaptable, have a look at those industries. Also [here](http://www.flexrule.com/archives/business-rule-engine-bre/) describes the differences between types of rules. Performance and scalability of rules execution depends on complexity of the rules and the algorithm they utilize to execute the rules. – Arash Aghlara Jul 17 '14 at 00:13
  • Not sure why some don't like this answer, but here is something to evaluate expression dynamically http://stackoverflow.com/questions/53844/how-can-i-evaluate-a-c-sharp-expression-dynamically If you don't do a heavy pattern matching, Drools as you mentioned is an overkill. If you are after a commercial one, you can check this [video](https://www.youtube.com/watch?v=vXIDYl7D1Rc) as well. (Disclaimer: I work for FlexRule.) – Arash Aghlara Aug 31 '15 at 01:07