Trying to make sense of rules...

6 views
Skip to first unread message

Bob Mattax

unread,
Aug 23, 2009, 10:51:54 PM8/23/09
to Ruleby
I've been struggling to wrap my brain around this whole method of
thinking.

I wouldn't say I'm an idiot, but trying to figure this all out is
making me feel dumb.

The gist of what I've gathered is:

1. Within the context of a rule engine, assert facts that exist in
your application
2. Write rules that somehow leverage these facts
3. Wait for the magic

The issues I'm having seem to revolve around how you manage whats
actually in the "working memory."

So, whenever I assert something, what actually happens to it? If I
insert an Item object, and then an array of Categories, how would I
write a rule that uses those?

I think I may just need to break everything down into smaller
decisions and take advantage of the logical node-linking.

Does anyone have suggestions for how to take business logic and break
them down into reasonable rules?

Thanks!

Joe Kutner

unread,
Aug 24, 2009, 10:57:20 PM8/24/09
to rul...@googlegroups.com
It sounds like you are looking for a more general intrduction to rule
engines. There are several good resources for this, including the
Drools documentation:

http://www.jboss.org/drools/documentation.html

Also check out some of the books I have listed on our wiki.

With respect to Ruleby, you might want to watch this talk I gave on
the subject:

http://rubyhoedown2008.confreaks.com/10-joe-kutner-ruleby-the-rule-engine-for-ruby.html

Thanks

Joe

Bob Mattax

unread,
Aug 24, 2009, 11:01:21 PM8/24/09
to Ruleby
I think I finally started to get it when I really started breaking
things down into the most granular "facts" I could think of.

One of my major hang-ups was finding a sensible place to store these
"in memory" facts. I ended up adding attributes to my models to hold
my fact "bits" and have made much more success this way. Is this
totally off base? Should I be approaching the memory space in some
other way?

Thanks for the video... I'll be watching it later.

On Aug 24, 10:57 pm, Joe Kutner <jpkut...@gmail.com> wrote:
> It sounds like you are looking for a more general intrduction to rule  
> engines. There are several good resources for this, including the  
> Drools documentation:
>
> http://www.jboss.org/drools/documentation.html
>
> Also check out some of the books I have listed on our wiki.
>
> With respect to Ruleby, you might want to watch this talk I gave on  
> the subject:
>
> http://rubyhoedown2008.confreaks.com/10-joe-kutner-ruleby-the-rule-en...
>
> Thanks
>
> Joe

Peter Lin

unread,
Aug 24, 2009, 11:26:36 PM8/24/09
to Ruleby

A great place to start is CLIPS manual, which is top notch. There's a
gold mine of knowledge in there.

http://groups.google.com/group/CLIPSESG/

once you have a decent understanding, the same knowledge and
techniques apply to other engines.

peter lin

Bob Mattax

unread,
Aug 25, 2009, 11:06:17 AM8/25/09
to Ruleby
So here is a chunk that I'm playing with:

http://gist.github.com/174748

As I said, I'm experimenting with breaking things up into these small
chunks. I've not had alot of success stringing any number of
conditions together, so I gave this route a shot and broke it all down
into tiny decisions. The trouble I'm having is that once I drop into
the block of the right hand side on :is_foo_ran_date_too_old , my vars
doesn't really contain my item attributes which should have been
adjusted in the :foo_date_unknown.

Does anyone see anything I'm doing wrong here?

Thanks,
Bob

Joe Kutner

unread,
Aug 25, 2009, 3:11:17 PM8/25/09
to rul...@googlegroups.com
Hmm, firing the rules and putting the rulebook in the before_save is
interesting. But it only allows you to assert one object at a time.
In the Store tutorial app, we fire off the rule engine in the
controller because we might have lots of model objects we want to
assert as rules (such as customer, product, etc) - and that's were we
want the business logic to live.

Matt has more experience than I do with integrating Ruleby into Rails
apps. He may be able to provide more insight on this. Any thoughts
Matt?

Joe
Reply all
Reply to author
Forward
0 new messages