Using untyped facts

114 views
Skip to first unread message

Bradley Van Aardt

unread,
Sep 10, 2013, 6:26:05 AM9/10/13
to no...@googlegroups.com
Hello all, 

I'm quite new to Node and rules engines in general, so please forgive any silly questions. 

For facts, I notice that the rules take in a type. Is this strictly necessary - In some cases I don't know the data type and what probably just use some kind of duck typing to check the object. I've hacked it currently by created a wrapper object and the matches then check various properties on the inner object. 

Am I looking for trouble doing this, in terms of performance or mis-firing rules?

Any info / comments appreciated, 

Thanks, 
Bradley

Douglas Martin

unread,
Sep 10, 2013, 7:18:05 PM9/10/13
to no...@googlegroups.com
It isn't "strictly necessary" in a sense, you could specify your type as 'Object' however it is highly recommended. The reason I say this is because when nools
evaluates your constraints it uses the object type to determine the constraints to evaluate, if you use Object as your type then all facts will be evaluated against that constraint making your rules less efficient. One way I use to narrow down the object types is to extend a parent "class" and use that to check object type which it sounds like you are doing.

I hope this helps.

-Doug

Bradley Van Aardt

unread,
Sep 11, 2013, 4:52:40 AM9/11/13
to no...@googlegroups.com
Hi Doug, 

Thanks for the reply. It makes sense - I had a suspicion there was a good reason for it :)


Bradley
Reply all
Reply to author
Forward
0 new messages