This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

A design question

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a query on a design question.
The requirement is as follows:
I have to develop a generic rule service. My application has list of possible rules as components (say Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7 and so on). Based on user input I have to trigger one or more of these rules. e.g
If input=1 then trigger Rule1, Rule2, Rule3
If input=2 then trigger Rule1, Rule2, Rule4
If input=3 then trigger Rule1, Rule2
If input=4 then trigger Rule5, Rule6, Rule7
and so on.
I have designed all rules to be implementing same interface(say RuleInterface).
RuleInterface has a single method as follows - execute()
My design approach is as follows:

Develop a RuleProcessor
which will have a attribute - Collection<Rule> ruleCollection
and a method process(int input) which will iterate each rule from rules and execute it.

My query is how do I design the set-up of ruleCollection attribute.One design I could think of is to populate all rules combination in DB and then use it to populate the ruleCollection attribute. Thus given above requirement, we will have 4 entries in DB (one for each input value). Is there a better and simple design possible(I am sure there is). I am tending to look at a design solution which is java based (and not necessarily dependent on DB) but am open to all the suggestions. I am using spring framework so if spring provides something out of the box then I would prefer that.

Thanks,
 
Pankaj Kumarkk
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can somebody please help on this. I would greatly appreciate this.

Thanks,
Pankaj
 
Saloon Keeper
Posts: 24548
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want user-designable decision logic (instead of logic that's permanently hard-coded in an app), you should look at one of the rule-based frameworks. One of the most famous such frameworks is Drools, which is now part of the JBoss project.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic