0

I have a little design dilemma. I have java and sql and no rules engine. I don't want to implement a full on rules engine either. My scenario: I have some input data, ie. code, description and an amount. Using these i will pass them into a function which will run lots of if else statements which are my business rules and will determine the output. I can do this in java, but the problem is that these codes and descriptions may change at anytime and so can the business rules, so my "if elses" need to change easily. My thought was given what i have to work with, is use a stored procedure in sql instead to manage the many if elses, and this can simply be changed by editing the stored proc and simply hitting f5, whereas with java, i'd have to modify the java code and recompile and deploy which takes much longer.

I would like to know if anyone has had such a problem and what were their experiences and successful approaches. The requirement is speed and being able to edit these business rules easily.

Thanks guys

Ken
  • 127
  • 2
  • 11
  • 2
    Could you give a more specific example of what you try to achieve? – Aron_dc Oct 23 '15 at 08:39
  • put aside logic in some properties and then just manupulate with this property file. you can change file whenever you want – ema Oct 23 '15 at 08:51
  • it seems that you need to "generalize" your business conditions (in IFs) to any metadata (stored in DB) and design any generic java code as the rule interpret ... but as [Aron_dc](http://stackoverflow.com/users/1579877/aron-dc) mentioned some example of your problem could clarify your needs – Marek-A- Oct 23 '15 at 08:54
  • i have a webservice call whos response gives me a code + description. Based on code and description i apply a whole bunch of business rules. These codes and descriptions can change at any time which means their rules may change. For example code 1, description "age0-10" maybe become code 2, with the same description. So the requirement there would be ability to change codes or descriptions easily. Then wrt rules part, we could change rule for code 1 with description "age0-10" to be something else. instead of if(code=1 and description="age0-10") then do x else do y could become the reverse. – Ken Oct 24 '15 at 09:29

1 Answers1

0

If your requirement is only changing values to check in if and else statements then the answer by ema is the right way to go. If your requirement is that also the logic must be changed and refreshed on the fly then you need to externalize it and deploy apart. There are several ways to do this. In my experience I've used drools a library rule engine from codehouse now from jboss that allow to build from very simple to very complex rules in a scriptable way so that you can deploy your files change and reload it. this is the link to their site http://www.drools.org/

Filippo Fratoni
  • 379
  • 2
  • 7