• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Looking for something more lightweight than a rules engine

 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Back in a different geological epoch I built a lot of expert systems. I'm a little rusty, but I think I can say that the system I used the most (TIRS), was a "frame-based" kind of system. Maybe not truly frame-based, but at least kind of frame-based. By "frame-based" I mean a system where you could create class-like templates (frames) and then instantiate them. Then, you could write "rules" that could take the general form:

if there exists an instance of frame X and
if there exists an instance of frame Y and
if there exists an instance of frame Z such that
X.a == Y.e and
X.b == Z.m and
Y.f == Z.n

then do stuff...


Sometimes it felt almost like weird, in-memory SQL queries.

Anyway, I have a Java app. where I need to create a lot of rules (maybe 25 to 50 rules?), like the one I showed above. A really horrible way to do it is to create nested loops (foreach X, Y, Z). I've written a few of those "rules" and they kind of make me throw up in my mouth a little

In my case, I think it's okay to hard code the order in which these rules will "fire" (be executed).

So the question is, is there a cleaner, fairly lightweight way to implement rules like this as a part of a larger Java app?

I remember looking at Jess a long time ago and feeling like it was very capable, but also probably not very lightweight from either a performance or "brain investment" perspective. Maybe I'm wrong about that?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know nothing about Rules Engines but I did fine a list of rules engines written in Java. Might help you find something "lighter".
 
Bert Bates
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Gregg,

I guess I posted this here because I'm wondering whether there is some sort of OO or patterns approach to this kind of design that I'm not familiar with. I'd really rather not go down any sort of "rules engine" approach if I can help it. These so-called "rules" are going to have to be executed thousands of times during an interaction.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel like I'm carrying coals to Newcastle here (or owls to Athens)...

Buschmann et al. discuss the Blackboard Architectural Pattern in Pattern-Oriented Software Architecture � A System of Patterns Volume 1 (POSA1) (pp.75-95) which may be applicable in this case.

However it would be difficult in a case like this to tell where you cross the line towards building your own microworld expert system/rules engine - at which point using a more general pre-existing implementation would make more sense.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recently caught a presentation on JESS at a Java conference. At first blush, I would consider a rules engine.

The 2 dominant ones seem to be JESS and Drools. JESS is based on older technology, and uses a Lisp-like syntax for the rules. However, the speaker said that it can execute 80K rules/second, so performance may not be a problem.

On the other hand, here is an entry-level article on Drools:

http://thediscoblog.com/2007/02/25/curtail-complexity-with-a-rules-engine/

On the _other_, other hand, I too have wondered about basic OO pattern that might work in simple instances. Imagine a Predicate interface like so:



A CompositePredicate could chain together individual predicates, where each one contains a given "rule". Things get a bit muddy here but I'm thinking of the composite pattern combined with a "filter" pattern. It is hard to tell if this would fit your situation.
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
josql is an interesting api that allows you to query in memory Objects. Not really a rules engine, but powerful...

http://josql.sourceforge.net/index.html
 
Bert Bates
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So far so cool!

That joSQL thingy looks pretty interesting. I'm open for more ideas, and I'll keep you all posted.
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bert,

I have used JBoss Rules in couple of Java Application. The results are quite good. I would strongly suggest to use this as it also have a small memory footprint.

Regards
Naveen
 
reply
    Bookmark Topic Watch Topic
  • New Topic