Which is better?

3 views
Skip to first unread message

Jake Dempsey

unread,
Oct 23, 2009, 2:24:20 PM10/23/09
to Ruleby
rule :Rule_Name,
[Class, :c1, m.method_that_returns_array(&c{|x| x.include?
("VALUE")})],
[Class2, :c2, m.type == "TYPE", m.relationship == b(:c1)] do |v|
puts "found it"
end

rule :Rule_Name2,
[Class2, :c2, m.type == "TYPE", m.relationship(&c{|x|
x.method_that_returns_array.include?("SHUTTLE")})] do |v|
puts "found it"
end


Is the first better because it doesnt have to execute the block on all
Class2 objects in the working memory? In the first approach I have to
assert each Class2 object and also assert its associated Class1
object. Doing this allows me to first scope by Class1. My assumption
is that if i have fewer Class1 objects it would be better to use the
first approach. Also, is my approach for arrays correct here?

Joe Kutner

unread,
Oct 23, 2009, 3:38:43 PM10/23/09
to rul...@googlegroups.com
Yes, the first rule would be better. It allows the engine to cache
matches of Class1.
Reply all
Reply to author
Forward
0 new messages