<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Pathfinder Development &#187; Business Rules</title>
	<atom:link href="http://www.pathf.com/blogs/category/business-rules/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pathf.com/blogs</link>
	<description>Running commentary about agile development, user experience design and Ajax.</description>
	<pubDate>Thu, 04 Dec 2008 21:00:14 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>GWT Showcase - BRMS for JBoss Rules</title>
		<link>http://www.pathf.com/blogs/2008/06/gwt-showcase-brms-for-jboss-rules/</link>
		<comments>http://www.pathf.com/blogs/2008/06/gwt-showcase-brms-for-jboss-rules/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 02:06:48 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Agile Ajax]]></category>

		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[Blaze Advisor]]></category>

		<category><![CDATA[GWT]]></category>

		<category><![CDATA[ILOG JRules]]></category>

		<category><![CDATA[RETE]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2008/06/gwt-showcase-brms-for-jboss-rules/</guid>
		<description><![CDATA[JBoss Rules (the former "Drools," though it's sad to see that cringe-inducing name making a comeback) is a Business Rules Engine (BRE). Those are the logic engines that allow you to execute a large set of "if-then" rules against a large set of facts (the most common algorithm to achieve this kind of performance is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pathf.com/blogs/wp-content/uploads/2008/06/brms-ruleexplorer.png"><img class="alignright size-medium wp-image-976" style="float:right;padding:10px;" title="brms-ruleexplorer.png" src="http://www.pathf.com/blogs/wp-content/uploads/2008/06/brms-ruleexplorer.png" alt="" width="300" height="134" /></a><a href="http://www.jboss.org/drools/" target="_blank">JBoss Rules</a> (the former "Drools," though it's sad to see that cringe-inducing name making a comeback) is a Business Rules Engine (<a href="http://en.wikipedia.org/wiki/Business_rules_engine" target="_blank">BRE</a>). Those are the logic engines that allow you to execute a large set of "if-then" rules against a large set of facts (the most common algorithm to achieve this kind of performance is called RETE, from the ancient Greek for "net"). For more on BRE's and how to use them, have a look at our <a href="http://www.pathf.com/blogs/category/business-rules/" target="_blank">Business Rules blog</a>.</p>
<p>One of the things that has differentiated commercial BRE's like <a href="http://www.fairisaac.com/fic/en/product-service/product-index/blaze-advisor/" target="_blank">Blaze Advisor</a> and <a href="http://www.ilog.com/products/jrules/" target="_blank">ILOG JRules</a> from the Open Source JBoss Rules is the tools. The commercial BRE's were part of a suite of development and management tools -- IDE's, "natural" language support, Business Rules Management Systems (<a href="http://en.wikipedia.org/wiki/BRMS" target="_blank">BRMS</a>) -- that made their use in a corporate IT "ecosystem" much easier.</p>
<p>With version 4 of JBoss Rules, you now get a powerful workbench plugin for Eclipse, support for Domain Specific Languages (DSL) that mimick natural language, and a web-based BRMS. With it you can deploy, roll back, and report on your rules.</p>
<p>The BRMS has a nice Ajax interface and is in fact written in GWT. This is a natural for a Java-based system like JBoss Rules. If the developers who use and develop JBoss Rules can also tinker with the BRMS interface (GWT==Java in the browser), the odds are better that the BRMS will evolve apace with the core system.</p>
<p>Compare this with a framework like <a href="http://wiki.nextapp.com/echowiki/Echo3" target="_blank">Echo2/3</a> where there is only a small cadre of developers who develop the JavaScript piece of what is essentially a Java centric framework, and consequently the development has lagged relative to other frameworks. So, good decision for JBoss Rules and probably a good decision if you are adding a web interface to your own Java system.</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2008/06/gwt-showcase-brms-for-jboss-rules/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Blogs Have Moved</title>
		<link>http://www.pathf.com/blogs/2008/05/the-blogs-have-moved/</link>
		<comments>http://www.pathf.com/blogs/2008/05/the-blogs-have-moved/#comments</comments>
		<pubDate>Sun, 25 May 2008 21:36:13 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Agile Ajax]]></category>

		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[TechDev]]></category>

		<category><![CDATA[UXD]]></category>

		<category><![CDATA[Announcement]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2008/05/the-blogs-have-moved/</guid>
		<description><![CDATA[After laboring away on Typepad because it was easy and, frankly, we had more important things to do, we have finally made the move to our own in-house blog. It now sits under the web site at http://www.pathf.com/blogs/ and combines our various blogs -- Agile Ajax, UXD, Business Rules and Techdev. You can still access [...]]]></description>
			<content:encoded><![CDATA[<p>After laboring away on Typepad because it was easy and, frankly, we had more important things to do, we have finally made the move to our own in-house blog. It now sits under the web site at <a href="http://www.pathf.com/blogs/">http://www.pathf.com/blogs/</a> and combines our various blogs -- Agile Ajax, UXD, Business Rules and Techdev. You can still access all of the sub-blogs individually through their feeds and category pages.</p>
<p>If you run into any issues (which I'm sure you will, given the contortions we had to go through to deal with Typepad's funky url's), drop us a line at <a href="mailto:info@pathf.com">info@pathf.com</a>.</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2008/05/the-blogs-have-moved/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Something to watch: Ruleby, a Ruby RETE Implementation</title>
		<link>http://www.pathf.com/blogs/2007/12/something-to-wa/</link>
		<comments>http://www.pathf.com/blogs/2007/12/something-to-wa/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 19:20:12 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[RETE]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2007/12/something-to-wa/</guid>
		<description><![CDATA[As Rails (and Ruby) climbs the hype curve, more and more systems are getting implemented that could benefit from a BRE. There are two (Rools and SIE) that don't use RETE. But Ruleby does, though it is in version 0.1...
]]></description>
			<content:encoded><![CDATA[<p>As Rails (and Ruby) climbs the hype curve, more and more systems are getting implemented that could benefit from a BRE. There are two (<a href="http://rools.rubyforge.org/">Rools</a> and <a href="http://homepage.ntlworld.com/peterhi/sie.html">SIE</a>) that don't use RETE. But <a href="http://rubyforge.org/projects/ruleby/">Ruleby</a> does, though it is in version 0.1 now. I'll post a couple of examples in it in the next couple of weeks.</p>
<p>Technorati Tags: <a class="performancingtags" href="http://technorati.com/tag/bre" rel="tag">bre</a>, <a class="performancingtags" href="http://technorati.com/tag/ruby" rel="tag">ruby</a>, <a class="performancingtags" href="http://technorati.com/tag/rails" rel="tag">rails</a>, <a class="performancingtags" href="http://technorati.com/tag/rete" rel="tag">rete</a>, <a class="performancingtags" href="http://technorati.com/tag/rools" rel="tag">rools</a>, <a class="performancingtags" href="http://technorati.com/tag/SIE" rel="tag">SIE</a>, <a class="performancingtags" href="http://technorati.com/tag/Ruleby" rel="tag">Ruleby</a></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2007/12/something-to-wa/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BRE Patterns III: Collaboration Cop, Part II</title>
		<link>http://www.pathf.com/blogs/2007/05/bre_patterns_ii/</link>
		<comments>http://www.pathf.com/blogs/2007/05/bre_patterns_ii/#comments</comments>
		<pubDate>Sun, 13 May 2007 02:58:18 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2007/05/bre_patterns_ii/</guid>
		<description><![CDATA[In explaining this pattern, I wanted to take a step back and explain where and how OO and BRE's intersect. To start with, this excellent post over at Mark Proctor's blog makes the following statement: Assert all your objects as...
]]></description>
			<content:encoded><![CDATA[<p>In explaining <a href="http://blogs.pathf.com/business_rules/2007/02/bre_patterns_ii.html" target="_blank">this pattern</a>, I wanted to take a step back and explain where and how OO and BRE's intersect. To start with, this <a href="http://markproctor.blogspot.com/2007/03/writing-better-rules.html" target="_blank">excellent post</a> over at Mark Proctor's blog makes the following statement:</p>
<blockquote>
<p>Assert all your objects as facts: Rule engines usually know how to handle a fairly heavy load of facts, so let the engine do its magic. If you want to reason over a nested set of objects, assert all of them (not only the top level ones) into the engine and make sure your business model models the relationship between them. After that, writing your rules will be easier and the engine will be able to optimize execution (when compared to using eval and other constructs to access deeply nested structures). Example: if you have an Order fact that contains a list of OrderItems, assert both Order and OrdemItems as facts (if you need to reason over OrderItems too, obviously).</p>
</blockquote>
<p>Why, by all that is object oriented, do you have to turn your domain model inside out, exposing what was hidden, unencapsulating what was encapsulated? Isn't this defeating the purpose of object orientation? The answer is, in short, yes. You are defeating the purpose of OO when you expose the innards of your model to the BRE. But it is a tradeoff. You get something for your trouble. Specifically, you get the super efficient rule matching of RETE and it's decendents.</p>
<p>This sort of exploding of the object model happens all the time in systems, and it isn't necessarily always bad. Alen Hollub (author of <a href="http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html"><em>Why getter and setter methods are evil</em></a> and other Edsger Dijkstra-like articles) has identified the "procedural boundary layer" and explains it nicely in his book <a href="http://www.amazon.com/Holub-Patterns-Learning-Design-Looking/dp/159059388X" target="_blank"><em>Holub on Patterns: Learning Design Patterns by Looking at Code</em></a>:</p>
<blockquote>
<p>One big exception exists to the no-getter-or-setter rule. I think of all OO systems as having a "procedural boundary layer." The vast majority of OO programs run on procedural operating systems and talk to procedural databases, for example. The interfaces to these external procedural subsystems are by their nature generic. The designer of JDBC hasn't a clue about what you'll be doing with the database, so the class design has to be unfocused and highly flexible. UI-builder classes such as Java's Swing library are another example of a "boundary-layer" library. The designers of Swing can't have any idea about how their classes will be used; they're too generic. Normally, it would be a bad thing to build lots of flexibility that you didn't use because it increases development time. Nonetheless, the extra flexibility is unavoidable in these boundary APIs, so the boundary-layer classes are loaded with accessor and mutator methods. The designers really have no choice.</p>
</blockquote>
<p>BRE's are not OO. Yes, the facts can be viewed as objects and the BRE's can be implemented using and OO language and design, but really the internal working of the BRE are most definitely not OO, the more the rule engine knows about each and every object and its innards, the more efficient it can be. Thus the PBL (procedural boundary layer) applies.</p>
<p>As an example why you need to expose all object, consider an order that is made up of line items.</p>
<p><code>public interface Order {<br/>[...]<br/>void addItem(OrderLineItem item);<br/>boolean removeItem(OrderLineItem item);<br/>[...]<br/>}</code></p>
<p>Now normally you would hide the details of all the line items inside the class that implements the Order interface. Let's suppose now that we haven't added any of the encapsulated line items to the working memory of the BRE's, just the order. Now let's say we update one of the line items through an operation. The only way we have to telling the BRE that something has changes is by flagging the enclosing Order object. That will trigger a reevaluation of every rule in which the Order plays a part, even ones where the line items play no part.</p>
<p>There are all sorts of ways of dealing with exposing the internals of your domain model to the BRE without breaking encapsulation. One way is to implement both the business interface and a bean interface (getters, setters, etc.) in the implementation (see diagram). The business interface is used within the domain model, the bean interface in the BRE.</p>
<p><a href="http://blogs.pathf.com/business_rules/BREExample.png" rel="lightbox" title="BREExample.png"><img src="http://blogs.pathf.com/business_rules/BREExample_tn.jpg" title="BREExample.png" height="167" width="200" alt="BREExample.png" border="0" id="urn:zoundry:jid:BREExample.png"/></a></p>
<p>Another approach is to wrap the domain objects in bean containers that access the private instance variables through reflection.</p>
<p>Of course lots of this depends on the specific BRE you are using. Some require you to expose your instance variables directly and don't deal well with method calls. I'd suggest not using those.</p>
<p>Next time I'll go through a simple example using JBoss Rules showing how to convert a domain model to a Collaboration Cop rule base.</p>
<p><br/>
<p class="zoundry_bw_tags">
<!-- Tag links generated by Zoundry Blog Writer. Do not manually edit. http://www.zoundry.com --><br />
<span class="ztags"><span class="ztagspace">Technorati</span> : <a href="http://technorati.com/tag/bre" class="ztag" rel="tag">bre</a>, <a href="http://technorati.com/tag/business%20rules" class="ztag" rel="tag">business rules</a>, <a href="http://technorati.com/tag/holub" class="ztag" rel="tag">holub</a>, <a href="http://technorati.com/tag/ooad" class="ztag" rel="tag">ooad</a>, <a href="http://technorati.com/tag/patterns" class="ztag" rel="tag">patterns</a>, <a href="http://technorati.com/tag/procedural%20boundary" class="ztag" rel="tag">procedural boundary</a></span></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2007/05/bre_patterns_ii/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Will JBoss Rules 3.1 Do for BRE&#8217;s What mySQL Did for RDBMS&#8217;?</title>
		<link>http://www.pathf.com/blogs/2007/04/will_jboss_rule/</link>
		<comments>http://www.pathf.com/blogs/2007/04/will_jboss_rule/#comments</comments>
		<pubDate>Sun, 22 Apr 2007 18:55:26 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[Drools]]></category>

		<category><![CDATA[JBoss Rules]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2007/04/will_jboss_rule/</guid>
		<description><![CDATA[While JBoss Rules 3.0.x has been a great step from its predecessor (the unfortunately named Drools) -- providing a rule editing environment, universal and existential quantifiers (the "not" A is the same as "for all" ~A), and Domain Specific Languages...
]]></description>
			<content:encoded><![CDATA[<p>While JBoss Rules 3.0.x has been a great step from its predecessor (the unfortunately named Drools) -- providing a rule editing environment, universal and existential quantifiers (the "not" A is the same as "for all" ~A), and Domain Specific Languages (DSL's) -- there were still a few things missing. I've watched the progress on 3.1 with barely contained excitement and impatience, but the result has been worth the wait. The <a href="http://markproctor.blogspot.com/2007/02/drools-31-milestone-1.html" target="_blank">3.1 M1 drop</a> contains operations on collections:</p>
<div class="code-quote">
<pre xml:space="preserve">
rule "Find interesting crash events, with 10 or more port scans within a 1 day window"
when
$crash : OutageEvent( eventType == OutageEvent.SERVER_CRASH)
ArrayList( size &gt; 9) from collect ( HackEvent(hackType == HackEvent.PORT_SCAN, $date : eventDate -&gt; (DateHelper.withinDayWindow($crash.getEventDate(), $date, 1))))
then
suspicious.add($crash);
end
</pre>
</div>
<p>There is also the accumulate operator, which is even more powerful than the collect operator. The documentation has lagged a little behind (it isn't a full on release, after all), but you can see some examples of it's use <a href="http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_Accumulate.drl" target="_blank">here</a>. I find that I use these sorts of collection operations quite a bit. That being said, the above rule isn't terribly efficient. If you have about 50 of those rules and lots of events of both categories, you will run into some cross-product hell (sort of like a poorly thought out database join). I'll show some ways of making this sort of rule more efficient in an upcoming entry.</p>
<p>Finally, the system now in theory allows better debugging of rulesets. The various views into the working memory have been around for a while. See below for some of my issues.</p>
<p><a href="http://blogs.pathf.com/business_rules/agendaview.PNG" rel="lightbox" title="agendaview.PNG"><img src="http://blogs.pathf.com/business_rules/agendaview_tn.jpg" title="agendaview.PNG" height="200" width="188" alt="agendaview.PNG" border="0" id="urn:zoundry:jid:agendaview.PNG"/></a></p>
<p>A few nits that I'm sure the JBoss Rules team will work out:</p>
<ul>
<li>The system desperately needs better syntax error handling in rule files. Right now the stack traces you get out of the parser/builder are pretty cryptic.</li>
<li>While you can now set breakpoints in the rule files, it doesn't seem that they are recognized by the debugging environment. As of now, you can only set breakpoints on a WorkingMemory fireAllRules call. Not that useful for debugging rule issues. I'm not sure if <a href="http://jira.jboss.com/jira/browse/JBRULES-313" target="_blank">this mod</a> is supposed to address that problem, but regardless, it would be handy to have a fireSingleRule call so one can control the execution of the rule engine more closely.</li>
<li>A real-time audit view to inspect engine events would be handy.</li>
<li>The graphical RETE display would be more useful if the nodes were labeled. A display showing the facts in each node during execution would be too much to hope for, but one can dream.</li>
</ul>
<p>The best thing about this latest version of JBoss Rules is, of course, that I can now start developing non-trivial examples and publishing them without having to constantly caveat that "this feature is present in Blaze and ILog, but not here." An even more interesting question is this: since JBoss Rules is getting close on being a reasonable alternative to some of the commercial products, will what happened in the database arena with mySQL also happen in the BRE arena? Will costs come down, interoperability increase? Will the commercial vendors concentrate on service, support and high end features? Will these same vendors become more open and share more information with the public? I don't think BRE's will ever be as widespread as RDBMS's, but I think the same dynamics might apply.</p>
<p>Some things to look forward to that I hope the JBoss Rules team is thinking about: rule management, specifically rule repositories and deployment management, e.g. revision control for rule sets and deployment of rule modifications to distributed, live production engines; Rule analytics, e.g. analysis of a rule set to see if it contains likely problems (infinite loops, possibly bad logic, etc.), and stats on actual rule execution, performance, etc.</p>
<p><br/>
<p class="zoundry_bw_tags">
<!-- Tag links generated by Zoundry Blog Writer. Do not manually edit. http://www.zoundry.com --><br />
<span class="ztags"><span class="ztagspace">Technorati</span> : <a href="http://technorati.com/tag/bre" class="ztag" rel="tag">bre</a>, <a href="http://technorati.com/tag/business%20rules" class="ztag" rel="tag">business rules</a>, <a href="http://technorati.com/tag/drools" class="ztag" rel="tag">drools</a>, <a href="http://technorati.com/tag/jboss%20rules" class="ztag" rel="tag">jboss rules</a></span></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2007/04/will_jboss_rule/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BRE Patterns III: Collaboration Cop, Part I</title>
		<link>http://www.pathf.com/blogs/2007/02/bre_patterns_ii-2/</link>
		<comments>http://www.pathf.com/blogs/2007/02/bre_patterns_ii-2/#comments</comments>
		<pubDate>Tue, 06 Feb 2007 05:28:24 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2007/02/bre_patterns_ii-2/</guid>
		<description><![CDATA[The pattern I'm writing about today -- Collaboration Cop -- is much meatier than the two previous ones, in my opinion. This one is all about transplanting the implicit and explicit business rules of an OO system from its objects...
]]></description>
			<content:encoded><![CDATA[<p>The pattern I'm writing about today -- Collaboration Cop -- is much meatier than the two previous ones, in my opinion. This one is all about transplanting the implicit and explicit business rules of an OO system from its objects to an external BRE.</p>
<p>This is a somewhat involved pattern, and I'll provide some more examples and references in part II. Also in part II, I'll run down the differences between the rule classifications that come out this pattern and the ones you commonly see in <a href="http://www.amazon.com/Principles-Business-Rule-Approach-Ronald/dp/0201788934" target="_blank">works by Ross</a>.</p>
<p><strong>Pattern Name: Collaboration Cop</strong></p>
<p><strong>Synopsis</strong><br/>Extract the business logic that is in an OO domain model -- collaboration rules, property rules and controller logic -- and express it as a set of business rules. Activity in the system is triggered by the UI inserting events into the working memory and firing the rules. Objects can be persisted by something like and ORM framework.</p>
<p>Slightly longer version: if you strip away the user interface and the persistence mechamism, a typical OO application is designed around a domain model and controller or service classes that set object collaborations within the domain model in motion in response to external events. The methods of the controller/service classes often correspond to steps in a <a href="http://en.wikipedia.org/wiki/Use_case" target="_blank">Use Case</a>. Embedded in the various domain classes is logic about how object can be modified and accessed, what collaborations can be created or desolved, etc. With this pattern, you extract all the service/controller and validation and collaboration logic into business rules. You populate the working memory with the objects that comprise the context for a Use Case. Finally, in response to an external event, you inject an event object into the working memory and fire the rules that modify the state of the object model (and persist it).</p>
<p><strong>Context<a href="http://blogs.pathf.com/business_rules/BRE3.PNG"><img src="http://blogs.pathf.com/business_rules/BRE3_tn.jpg" style="DISPLAY: inline; FLOAT: right; WIDTH: 200px; HEIGHT: 153px" title="BRE3.PNG" height="153" width="200" alt="BRE3.PNG" border="0" id="BRE3.PNG"/></a></strong><br/>Take the somewhat simplified Use Case where a customer is trying to rent a tape (he's a sucker for punishment and doesn't like DVD's). In a OO system, we would try to create a collaboration as follows (yes, very simplified):</p>
<p><code>customer.addRental(new Rental(title.getTape()));</code></p>
<p>The <code>customer</code> object knows how many active rentals a customer has and knows hat he cannot have more than three. This attempted collaboration would throw an exception to indicate that it is not permitted.</p>
<p>In the Collaboration Cop version we would create an event and insert it into the working memory:</p>
<p><code>VideoStoreEvent event = new VideoStoreEvent();<br/>event.type = VideoStoreEvent.RENT_TAPE;<br/>event.value = "Gone With the Wind";<br/></code></p>
<p><code>IF event.type == <span style="FONT-FAMILY: Courier New">VideoStoreEvent.RENT_TAPE</span> AND title.getTitle() == event.value AND title.isInStock()<br/>AND customer.activeRentals() &lt; 3<br/>THEN<br/>customer.addRental(new Rental(title.getTape()));<br/>externalObjectSet.add(customer);<br/>externalResponse.message = "Rented tape.";<br/>externalResponse.success = true;<br/>ELSE<br/>externalResponse.message = "Unable to rent tape.";<br/>externalResponse.success = false;</code></p>
<p>You can wrap a transaction around the sequence of event injections, then save (using an ORM) all of the modified objects in the <code>externalObjectSet</code>.</p>
<p>-----------</p>
<p>This pattern is complex and powerful, and it's implementation is very much dependent on the capabilities of the chosen BRE, how you choose to deal with concurrency, etc.. In part II, I'll also construct a simple example using JBoss Rules.</p>
<p><br/>
<p class="zoundry_bw_tags">
<!-- Tag links generated by Zoundry Blog Writer. Do not manually edit. http://www.zoundry.com --><br />
<span class="ztags"><span class="ztagspace">Technorati</span> : <a href="http://technorati.com/tag/bre" class="ztag" rel="tag">bre</a>, <a href="http://technorati.com/tag/business%20rules" class="ztag" rel="tag">business rules</a>, <a href="http://technorati.com/tag/patterns" class="ztag" rel="tag">patterns</a></span></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2007/02/bre_patterns_ii-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Resources and Announcements</title>
		<link>http://www.pathf.com/blogs/2006/09/resources_and_a/</link>
		<comments>http://www.pathf.com/blogs/2006/09/resources_and_a/#comments</comments>
		<pubDate>Sun, 03 Sep 2006 19:51:59 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[RETE]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/09/resources_and_a/</guid>
		<description><![CDATA[It's been a busy month that has taken me away from focusing on Business Rules, but things are almost back to normal and I should have another entry on BRE patterns out this coming week. In the meantime, I thought...
]]></description>
			<content:encoded><![CDATA[<p>It's been a busy month that has taken me away from focusing on Business Rules, but things are almost back to normal and I should have another entry on BRE patterns out this coming week. In the meantime, I thought I'd share with you two interesting resources that I came across recently.</p>
<p>The first is <a href="http://www.mindswap.org/~katz/pychinko/" target="_blank">Pychinko</a>, a native Python RETE-based business rule engine. This points out that Java, C# and C are not the only languages that can benefit from a business rules approach. In fact, as you'll see in my next BRE patterns entry, I'd argue that object orientation and business rules are a natural fit, regardless of the specific language used. If your requirements call for any sort of embedded scripting, this solution might be worth considering.</p>
<p>I'm experimenting with a new way of finding resources on the Internet. With this new method, I was able to find the second item, a thorough introduction to business rules and RETE over at InfoQ, entitled <a href="http://www.infoq.com/articles/Rule-Engines" target="_blank">Real-World Rule Engines</a>. The article covers quite a bit of territory. Among the topics addressed are:</p>
<ul>
<li>What are rule engines</li>
<li>How do you use them</li>
<li>Architecting with Rule Engines</li>
<li>Managing Rules</li>
<li>Rule Engine Patterns and Anti-Patterns</li>
<li>Governance</li>
<li>Thoughts on rule writing</li>
</ul>
<p>Definitely a good resource for those wanting to get started with business rules engines.</p>
<p>Last, I wanted to pass on the news that James Taylor has moved his blog over to a new url: <a href="http://www.edmblog.com/weblog" target="_blank" title="http://www.edmblog.com/weblog">http://www.edmblog.com/weblog</a>. If you are a regular reader of his blog, you already probably know this. If you aren't a regular reader of his blog, you really should be.</p>
<p class="zoundry_bw_tags">
&nbsp; <br />
&nbsp; <span class="ztags"><span class="ztagspace">Technorati</span> : <a href="http://technorati.com/tag/RETE" class="ztag" rel="tag">RETE</a>, <a href="http://technorati.com/tag/business%20rules" class="ztag" rel="tag">business rules</a></span> </p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/09/resources_and_a/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JBoss Rules Wiki - A Business Rules Community of Practice</title>
		<link>http://www.pathf.com/blogs/2006/08/jboss_rules_wik/</link>
		<comments>http://www.pathf.com/blogs/2006/08/jboss_rules_wik/#comments</comments>
		<pubDate>Fri, 25 Aug 2006 17:01:15 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[Drools]]></category>

		<category><![CDATA[JBoss Rules]]></category>

		<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/08/jboss_rules_wik/</guid>
		<description><![CDATA[The guys over at JBoss Rules are starting to build a little community of practice over in their Wiki. There's a ton of good stuff over there, including a link to this tutorial by Arnaud Blandin that teaches in some...
]]></description>
			<content:encoded><![CDATA[<p></p>
<p>The guys over at JBoss Rules are starting to build a little community of practice over in their <a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossRules" target="_blank">Wiki</a>.</p>
<p></p>
<p>There's a ton of good stuff over there, including a link to <a href="http://bpms.intalio.com/content/view/121/87/" target="_blank">this tutorial</a> by <span class="content-author">Arnaud Blandin that teaches in some great detail on how to integrate the JBoss Rules engine into your business process. Even if you're not open to open source or leaning toward a commercial product like Blaze or JRules, JBoss Rules is a great way to get your feet wet and get up the steep BRE learning curve. It certainly helps knowing what the heck a BRE is and what it can do when you are making decisions on how to integrate it into your software ecosystem. (Imagine trying to buy a database if your company has never used a database before. Would you know what to look for and what was important?)</span></p>
<p></p>
<p class="zoundry_bw_tags">
<!-- Tag links generated by Zoundry Blog Writer. Do not manually edit. http://www.zoundry.com --><br />
<span class="ztags"><span class="ztagspace">Technorati</span> : <a href="http://technorati.com/tag/jboss%20rules" class="ztag" rel="tag">jboss rules</a>, <a href="http://technorati.com/tag/usage%20patterns" class="ztag" rel="tag">usage patterns</a></span> 
</p></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/08/jboss_rules_wik/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Performance Comparison of Jess, Drools and MS-BRE</title>
		<link>http://www.pathf.com/blogs/2006/08/a_performance_c/</link>
		<comments>http://www.pathf.com/blogs/2006/08/a_performance_c/#comments</comments>
		<pubDate>Wed, 16 Aug 2006 18:36:57 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[Benchmarking]]></category>

		<category><![CDATA[Drools]]></category>

		<category><![CDATA[JBoss Rules]]></category>

		<category><![CDATA[Jess]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/08/a_performance_c/</guid>
		<description><![CDATA[I have to apologize in advance. I'm in the middle of squeezing out a book chapter and haven't had time to tackle any of the BRE articles on my writing TODO list. So today I'm going to have to do...
]]></description>
			<content:encoded><![CDATA[<p></p>
<p>I have to apologize in advance. I'm in the middle of squeezing out a book chapter and haven't had time to tackle any of the BRE articles on my writing TODO list. So today I'm going to have to do what I usually hate to do -- become a blog echo chamber. The post I want to alert you to is one posted almost a year ago by Charles Young, entitled <a href="http://geekswithblogs.net/cyoung/articles/54022.aspx" target="_blank">Microsoft's Rule Engine Scalability Results - A comparison with Jess and Drools</a>. The article claims to show that Microsoft's BRE cannot be criticized about not implementing RETE properly based on MS's published test results. That's a long way to go for such an ephemeral point.</p>
<p></p>
<p>I don't recommend the article because of the claims it makes, but rather because it both demonstrates the use of three different BRE's through actual code samples, and it provides an approach to benchmarking and comparing BRE's for scalability and performance. I'm a <a href="http://blogs.pathf.com/business_rules/2006/04/exagerated_clai.html">firm believer</a> in benchmarking BRE's based on your actual use cases rather than on abstract worst-case scenarios like Miss Manners. Read through this blog entry. Even if his approach is flawed, as I believe it is, he deserves full credit for publishing the full code to his test and opening it up to public scrutiny.</p>
<p></p>
<p class="zoundry_bw_tags">
<!-- Tag links generated by Zoundry Blog Writer. Do not manually edit. http://www.zoundry.com --><br />
<span class="ztags"><span class="ztagspace">Technorati</span> : <a href="http://technorati.com/tag/drools" class="ztag" rel="tag">drools</a>, <a href="http://technorati.com/tag/jboss%20rules" class="ztag" rel="tag">jboss rules</a>, <a href="http://technorati.com/tag/jess" class="ztag" rel="tag">jess</a>, <a href="http://technorati.com/tag/microsoft" class="ztag" rel="tag">microsoft</a>, <a href="http://technorati.com/tag/performance" class="ztag" rel="tag">performance</a>, <a href="http://technorati.com/tag/scalability" class="ztag" rel="tag">scalability</a></span> 
</p></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/08/a_performance_c/feed/</wfw:commentRss>
		</item>
		<item>
		<title>OpenCyc 1.0 Released</title>
		<link>http://www.pathf.com/blogs/2006/08/opencyc_10_rele/</link>
		<comments>http://www.pathf.com/blogs/2006/08/opencyc_10_rele/#comments</comments>
		<pubDate>Thu, 10 Aug 2006 19:24:42 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/08/opencyc_10_rele/</guid>
		<description><![CDATA[OpenCyc 1.0 was quietly released today. It doesn't bill itself as a Business Rule Engine. Instead, from the FAQ: What is OpenCyc? OpenCyc is the open source version of the Cyc technology, the world's largest and most complete general knowledge...
]]></description>
			<content:encoded><![CDATA[<p></p>
<p><a href="http://www.opencyc.org/" target="_blank">OpenCyc 1.0</a> was quietly released today. It doesn't bill itself as a Business Rule Engine. Instead, from the FAQ:</p>
<p></p>
<blockquote><p></p>
<p><strong>What is OpenCyc?</strong></p>
<p></p>
<p>OpenCyc is the open source version of the Cyc technology, the world's largest and most complete general knowledge base and commonsense reasoning engine. Cycorp, the builders of Cyc, have set up an independent organization OpenCyc.org, to disseminate and administer OpenCyc, and have committed to a pipeline through which all current and future Cyc technology will flow into ResearchCyc (available for R&amp;D in academia and industry) and then OpenCyc.</p>
<p></p>
<p>What is included with the first release of OpenCyc?</p>
<p></p>
<p>Release 1.0 of OpenCyc will include the following:</p>
<p></p>
<ul></p>
<li>6,000 concepts: an upper ontology for all of human consensus reality.</li>
<p></p>
<li>60,000 assertions about the 6,000 concepts, interrelating them, constraining them, in effect (partially) defining them.</li>
<p></p>
<li>A compiled version of the Cyc Inference Engine and the Cyc Knowledge Base Browser.</li>
<p></p>
<li>A suite of "RKF" tools for rapidly extracting knowledge from a domain expert (e.g., a physician or oil drilling specialist), tools which operate by carrying on a clarification dialogue with that individual; hence: tools for answering questions via English dialogue.</li>
<p></p>
<li>Documentation and self-paced learning materials to help users achieve a basic- to intermediate-level understanding of the issues of knowledge representation and application development using Cyc.</li>
<p></p>
<li>A specification of CycL, the language in which Cyc (and hence OpenCyc) is written. There are CycL-to-Lisp, CycL-to-C, etc. translators.</li>
<p></p>
<li>A specification of the Cyc API, by calling which a programmer can build an OpenCyc application with very little familiarity with CycL or with the OpenCyc KB.</li>
<p></p>
<li>A few sample programs that demonstrate use of the Cyc API for application development.</li>
<p>
</ul>
<p>
</p></blockquote>
<p></p>
<p>According to the docs, the inference engine is not RETE but instead a mix of specialized techniques. Also, said engine is not actually open source but instead distributed under a perpetually free license.</p>
<p></p>
<p>I'm going to reserve comment on the usefulness or quality of the software, but the ontology and the knowledge-base are probably worth some study.</p>
<p></p>
<p>Update 1: There are some comments that give a little bit more texture on Cyc from a <a href="http://suo.ieee.org/email/msg06534.html" target="_blank">IEEE mailing list</a>.</p>
<p></p>
<p class="zoundry_bw_tags">
<!-- Tag links generated by Zoundry Blog Writer. Do not manually edit. http://www.zoundry.com --><br />
<span class="ztags"><span class="ztagspace">Technorati</span> : <a href="http://technorati.com/tag/cyc" class="ztag" rel="tag">cyc</a>, <a href="http://technorati.com/tag/inferencing%20engine" class="ztag" rel="tag">inferencing engine</a>, <a href="http://technorati.com/tag/knowledge%20base" class="ztag" rel="tag">knowledge base</a>, <a href="http://technorati.com/tag/opencyc" class="ztag" rel="tag">opencyc</a></span> 
</p></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/08/opencyc_10_rele/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is a BRE Turing Complete?</title>
		<link>http://www.pathf.com/blogs/2006/08/is_a_bre_turing/</link>
		<comments>http://www.pathf.com/blogs/2006/08/is_a_bre_turing/#comments</comments>
		<pubDate>Tue, 01 Aug 2006 14:00:00 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/08/is_a_bre_turing/</guid>
		<description><![CDATA[Mark Proctor of the JBoss Rules team gave me the heads up about an interesting debate (here and here) about First Order Logic (FOL) and whether various BRE's do or should support it. One question that has come up is...
]]></description>
			<content:encoded><![CDATA[<p>Mark Proctor of the JBoss Rules team gave me the heads up about an interesting debate (<a href="http://woolfel.blogspot.com/2006/07/should-rule-engine-support-fol.html" target="_blank">here</a> and <a href="http://www.jboss.com/index.html?module=bb&amp;op=viewtopic&amp;p=3960753" target="_blank">here</a>) about First Order Logic (FOL) and whether various BRE's do or should support it. One question that has come up is whether BRE's can still be said to be Turing Complete? Actually, the two questions -- whether a BRE supports FOL and whether it is Turing Complete -- are quite seperate.</p>
<p><strong>Turing Complete</strong></p>
<p>First the easy question: when is a system Turing Complete? From the Wikipedia:</p>
<blockquote>
<p><em>In computability theory, an abstract machine or programming language is called Turing complete, Turing equivalent, or (computationally) universal if it has a computational power equivalent to (i.e., capable of emulating) a simplified model of a programmable computer known as the universal Turing machine. Being equivalent to the universal Turing machine essentially means being able to perform any computational task - though it does not mean being able to perform such tasks efficiently, quickly, or easily.</em></p>
</blockquote>
<p>So, what is a Turing machine? Again you can look at the <a href="http://en.wikipedia.org/wiki/Turing_machine" target="_blank">Wikipedia</a>, but in a nutshell, it's a tape with an infinite number of cells, a read/write head, a finite alphabet that the head can write to a cell, a finite number of 'states' that the machine can be in, and a finite number of rules that say things like "if you are in state 3 and the symbol on the tape is '0', the write a '1', move the head one cell to the right and change your state to 8."</p>
<p>While this may seem like a silly sort of machine (just try to write a word processor with it), it can do anything, given the right number of states and the right set of rules, that a <a href="http://en.wikipedia.org/wiki/Von_Neumann_architecture" target="_blank">von Neuman</a> style of computer -- essentiall the sort of computer with which you are reading this blog -- can do. It's handy for proving certain theorems about computability and complexity. If you can write any Turing machine with your device, then it is said to be a Universal Turing Machine, i.e. if you can compute it with an algorithm, you can do it with your machine. It should be obvious that a BRE, even without First Order Logic, is a UTM. We can have a fact that tells us what our state is, another fact that tells us where our read/write head is, a set of facts that represent all of the cells we've seen so far, and our rules that govern how our state, head and cells are modified. Therefore a BRE is Turing Complete.</p>
<p>Of course there's a small fly in the ointment. Up above we said that a turing machine had an "infinite" number of cells. Of course your computer can't accomodate an infinite number of cells, since it has a finite amount of memory and storage. This is a rather important point, as it turns out. Anything program running on a modern computer with finite memory and storage is at best a <a href="http://en.wikipedia.org/wiki/Finite_state_automaton" target="_blank">Finit State Machine</a>, basically the most primite of the interesting algorithms. But in principle, a BRE with infinite memory is Turing Complete.</p>
<p><strong>First Order Logic</strong></p>
<p>I'll try to stay a little non-technical here, mostly because all of my math text books are in storage. First Order Logic (or First Order Predicate Logic) is an extension of regular propositional logic with the addition of the universal and existential quantifiers. That means we can write conditions in our rules that are true <strong>for all</strong> facts of a particular type in our fact base or which are true <strong>for at least one</strong> fact. I've <a href="http://blogs.pathf.com/business_rules/2006/03/first_order_log.html">written before</a> why having First Order Logic built into your BRE is a good thing. In short, you can work around your BRE not having it, but you'll lose the performance advantage of your rule execution algorithm in the process, such as RETE. And there are plenty of scenarios where you are looking at an event history of a customer or client that call for FOL.</p>
<p>You can see, however, that our simulation of a Turing machine above never called for a quantifier. Thus even a BRE without FOL is Turing Complete (if it has infinit memory, yada yada). I hope this explanation I hope this entry has been useful and not too geeky. Behind all of the hype behind BRE's, it is sometimes useful to understand what exactly they are and what they can do.</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/08/is_a_bre_turing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Short Circuited OR Considered Harmful</title>
		<link>http://www.pathf.com/blogs/2006/07/the_short_circu/</link>
		<comments>http://www.pathf.com/blogs/2006/07/the_short_circu/#comments</comments>
		<pubDate>Tue, 25 Jul 2006 14:00:00 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[Best Practices]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/07/the_short_circu/</guid>
		<description><![CDATA[In my discussions with James Taylor about using wizards to write rules, I was reminded of some cases where it was necessary to create a wizard for this purpose. They all shared two things in common: the need for justifications...
]]></description>
			<content:encoded><![CDATA[<p>In my discussions with <a href="http://edmblog.fairisaac.com/" target="_blank">James Taylor</a> about <a href="http://www.realrules.info/?q=node/39" target="_blank">using wizards to write rules</a>, I was reminded of some cases where it was necessary to create a wizard for this purpose. They all shared two things in common: the need for justifications and non-shortcircuited OR's. Let me give you an example.</p>
<p>Let's suppose you are designing a system that decides whether or not to recommend prisoners for early release. Your facts inlcude the prisoners' criminal records, the details of their behavior behind bars, recommendations by prison officials and the district attourney, enrollment in treatment and rehabilitation programs, and mitigating circumstances such as aged parent or infirm spouses or children. You formulate the state's sentencing and release guidelines as business rules and implement them in your vendor platform of choice. When a feed of data comes from the department of corrections, you add it to your database and run it through your rule system which issues recommendations to a board charged with making the final decision. This board makes a judgement call based on the information you provide them.</p>
<p>When they look at your recommendation, they don't just want to see a yes or no, they want to see an <strong>explanation</strong> or <strong>justification</strong>. Something like "Prisoner Joe Smith, #54-56, is not recommended for release because he had at least 3 incidents of misbehavior in the last 6 months and was convicted of at least a Class C felony." Ideally, you'd want to spell out exactly what the issues were:</p>
<blockquote>
<p>Prisoner: Joe Smith<br/>Number: 54-56<br/>Recommended for Early Release: No<br/>Reasons: At least 3 incidents of misbehavior in the last 6 months (stabbing of guard, 4/5/2006; assault of fellow prisoner, 4/22/2006; contraband in cell, 5/17/2006) AND convicted of at least a Class C felony (Criminal Possession of Stolen Property, 6/11/2004)</p>
</blockquote>
<p>Now as a board member, I can look at the prisoner and see that while he was convicted of a nonviolent crime, he looks to have been violent while in prison. If he had just been flagged for contraband, maybe I might consider releasing him.</p>
<p>OK, so justification is useful in this context, as it is in many other fields, like healthcare, insurance underwriting and claims, criminal science, etc. How do we produce a justification with our rule engine? The sad truth is that none of the commercial vendors of forward-chaining BRE's will do that for you automatically. You have to roll your own. One approach is to use the <a href="http://blogs.pathf.com/business_rules/2006/05/bre_patterns_i.html">Fact Harvest pattern</a> to construct and build a <code>ReleaseRecommendation</code> object. This fact would tell us whether a particular prisoner was recommended for release (true or false) and all of the conditions that contributed to this recommendation. It might contain a list of all of the misbehavior's over the last 6 months and the crime for which he was convicted.</p>
<p>Here we come to the first reason for using a wizard to write rules: if you are testing a particular condition in the 'IF' part of your rule and then updating your <code>ReleaseRecommendation</code> object with the details of that same condition in the 'THEN' part of the rule, <strong>you're essentially recapitulating the condition in the action part of the rule</strong>. Aside from being a pain in the neck, it's also a maintenance problem. Every time you update a condition, you have to make sure to update the corresponding action. If you don't, Charles Manson gets released by accident -- or, rather, because of your bug. It voilates the DRY principle (Don't Repeat Yourself). One way of handling this is to have your wizard generate the rule for you, with both the condition and action parts. Now you make one change and the rule is generated in a way that is guaranteed to maintain consistency.</p>
<p>The second reason for using a wizard has to do with the short-circuited OR of the title. If our rule above actually tests for</p>
<blockquote>
<p><em>has had at least 3 incidents of misbehavior in the last 6 months OR is a drug addict</em></p>
</blockquote>
<p>then what happens with our rule? If you've programmed much, you know that most languages use what is known as "short-circuited OR," i.e. if you are testing A OR B and A evaluates to true, then B is never tested. If you are depending on side effect of B (such as the building of a list of incidents, etc.), you can forget about it ever happening. The 'is a drug addict' part of the condition is never tested. To make things worse, if we are constructing a justification, we have to test in the action which parts of the OR clause in the condition actually evaluated to true. Imagine now a complex condition with lots of OR, NOT's, AND's and parentheses. Yuck.</p>
<p>A way around this mess is to break apart the OR clause into seperate rules and accumulating them in the <code>ReleaseRecommendation</code> object. The drawback, of course, is that now we have to create several rules where before we had only one. Again, generating these rules with a wizard is a more or less elegant way out.</p>
<p>If anyone has a niftier solution to justification or non-short-circuited OR, I'm more than happy to hear about it.</p>
<p>Update 1: Michael Chermside correctly points out in the comments that it would be more elegant to have a justification engine that worked directly with the BRE's internals. I agree. Unfortunately, none of the forward-chaining BRE's I've worked with have very good support for justification or supply hooks into their internals to support the building of a justification engine through AOP or something equivalent. If you work with an open source engine like JBoss Rules, you can build in your own justification logic.</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/07/the_short_circu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Why Your Engine Should Support Programmatic Rule Generation</title>
		<link>http://www.pathf.com/blogs/2006/07/why_your_engine_1/</link>
		<comments>http://www.pathf.com/blogs/2006/07/why_your_engine_1/#comments</comments>
		<pubDate>Sun, 23 Jul 2006 17:36:26 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/07/why_your_engine_1/</guid>
		<description><![CDATA[I've published an article over at the RealRules Blogzine on programmatic generation of rules, i.e. why and under what circumstances this makes sense. Check it out.
]]></description>
			<content:encoded><![CDATA[<p></p>
<p>I've published an article over at the <a href="http://www.realrules.info/" target="_blank">RealRules Blogzine</a> on programmatic generation of rules, i.e. why and under what circumstances this makes sense. <a href="http://www.realrules.info/?q=node/39">Check it out</a>.</p>
<p></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/07/why_your_engine_1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Your Business Rule System is a Fool</title>
		<link>http://www.pathf.com/blogs/2006/07/what_do_you_mea/</link>
		<comments>http://www.pathf.com/blogs/2006/07/what_do_you_mea/#comments</comments>
		<pubDate>Thu, 20 Jul 2006 13:00:00 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[Best Practices]]></category>

		<category><![CDATA[Consistency]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/07/what_do_you_mea/</guid>
		<description><![CDATA[He who knows not, and knows not that he knows not, is a fool - shun him. He who knows not, and knows that he knows not, is a child - teach him. He who knows, and knows not that...
]]></description>
			<content:encoded><![CDATA[<blockquote><em>He who knows not, and knows not that he knows not, is a fool - shun him.<br/>He who knows not, and knows that he knows not, is a child - teach him.<br/>He who knows, and knows not that he knows, is asleep - wake him.<br/>He who knows, and knows that he knows, is a wise man - follow him.</em></p></blockquote>
<p>The above is either an Arabic, Persian or Chinese proverb. I known not, so take your pick. But you could learn something from it for your business rules project.</p>
<p>Even after you've gone through the trouble of pulling your business rules out of existing applications and processes and centralizing them in a rule repository, you could still face problems of a logical or informational variety. You're business rule system may not have the necessary data, or it may have wrong data, or it may have the wrong kind of facts. The system may further not have all the right rules, or some bad rules or it may even come up with some unpleasant conclusions you didn't expect at all. In short, it may be a fool, a child, asleep or even a wise man, all at once, and even a few other choice epithets not included in the above proverb.</p>
<p>To make sure your business rule system behaves well, there are a few specific factors you should consider. I'll blog about them in the next few weeks, digging a little deeper and proposing some remedies along the way:</p>
<ul>
<li>
<p>Data (or Fact) Consistency - If you've got Joe being both 16 and 45 years old, you've got a problem. If that situation seems absurd to you, I tip my hat. You're clearly one of the chosen few whose data is consistent across all of your firms databases. <img src='http://www.pathf.com/blogs/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> The kinds of data inconsistencies can go much farther, such as a 5-year-old having a husband, or a dead man requiring a liver transplant. The solutions to these data consistency problems are for the most part very unglamorous techniques from the world of data modeling.</p>
</li>
<li>
<p>The Wrong Kinds of Facts - If you've ever design OO software or designed a database, you know what I'm talking about. If your entities are the wrong kind, the wrong size, or incomplete, you will kill yourself writing awkward code. These entities and associated behaviors are like your nouns, verbs and adjectives. Pick the wrong words and your sentences are hard to write. If you capture only the final bill in a system and not the details of the transaction that incurred the bill, you may still be able to extrapolate the transaction information, but you have to work harder to do it. Too much hard work and the system limits rather than enables your ability to describe your business rules.</p>
</li>
<li>
<p>Rule Consistency - What if given a clean, consistent set of facts, your rule set allows you to arrive at A and Not A -- "Joe is a minor" and "Joe is an adult?" With a few hundred or a thousand rules in your set, this problem may be hard to discover. (I'd add rule execution order independence to this category.) In fact, tracking down rule inconsistencies can be a bit tricky, with a couple of not quite satisfactory solutions available.</p>
</li>
</ul>
<p>We'll leave off from things like <a href="http://en.wikipedia.org/wiki/Decidability_(logic)" target="_blank">decidability</a>, as they probably don't have much bearing on BRE's, and cross product matching, as that's really more of a performance issue. I would advise you to be prepared, however, for your cauldron of rules and facts to sometimes deliver you some unexpected results. If you've done more than just 1 + 1 = 2, they can surprise you and perhaps grow past your own abilities. You've built a child and taught it to be a wise man -- or maybe it's just a fool that's mouthing off.</p>
<p><br/><br/></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/07/what_do_you_mea/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Conflict Resolution - Why BRE&#8217;s Give Different Results</title>
		<link>http://www.pathf.com/blogs/2006/07/conflict_resolu/</link>
		<comments>http://www.pathf.com/blogs/2006/07/conflict_resolu/#comments</comments>
		<pubDate>Tue, 11 Jul 2006 14:00:00 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[JSR-94]]></category>

		<category><![CDATA[RETE]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/07/conflict_resolu/</guid>
		<description><![CDATA[A while back in 2004, Daniel Selman, the JSR-94 Specification Lead, published an article on the future of the specification. It's well worth reading in any case, but one particular observation stuck out: In my opinion the root problem is...
]]></description>
			<content:encoded><![CDATA[<p>A while back in 2004, Daniel Selman, the JSR-94 Specification Lead, published <a href="http://www.javarules.org/index.php?name=News&amp;file=article&amp;sid=23" target="_blank">an article</a> on the future of the specification. It's well worth reading in any case, but one particular observation stuck out:</p>
<blockquote><p><em>In my opinion the root problem is not the lack of a standard rule language, it is the lack of a standard execution semantic for rule engines.</em></p>
</blockquote>
<p>What the heck does that mean and why is it important? Well, without getting too technical, a BRE engine has a way of expressing rules. This way of expressing rules constitues a programming language. Any programming language has a syntax -- what are the valid programs, made up of keywords, identifiers, operators, etc. that can be written in the language -- and semantics -- what the program actually means or does. There are ways of formally specifying the semantics of a programming language, typically by translating the programming language into another language that already has a semantics or by mapping a trace-based semantics to the syntax of the language. I said &quot;without getting too technical,&quot; so we won't go there.</p>
<p>In the case of BRE rule-sets, we can think of them being translated into data structures for a production systems pattern matching algorithm such as the RETE algorithm, which provides the execution semantics for the rule language. There are at least two ways that this can make for different semantics, i.e. different results from the execution of a rule-set. First, different algorithms can have different execition semantics, i.e. they process the rule-sets in ways different enough to give different results. Second, some parts of an algorithm can be variable.</p>
<p>The one bit of variability that immediately comes to mind is conflict resolution. Whenever a rule engine evaluates a rule-set, there is a likelihood that more than one rule will be activated. How to choose amongst these rules? There are a few different conflict resolution algorithms, each designed to achieve a different effect. Just a few examples:</p>
<ul>
<li>Salience. This is where the rule author assigns a priority to a particular rule. The highest priority rule is picked from all the matching rules. In a medical scenario, you may want the cancer rules to have a higher priority than the asthma ones.</li>
<li>Longest matching. With this strategy, you execute the rules with the most number of clauses, i.e. the greatest number of AND'ed an OR'ed conditions. The idea here is that the rule with the most clauses is the most specific and should be fired first.</li>
<li>Newest facts. Here the rule that was triggered by the newest fact or facts takes precedence. If you view the firing of foward chaining rules, this is sort of like a depth-first search -- keeping going down the branch that generated the latest new facts.</li>
<li>Don't choose instantiations that have previously fired. If a rule already matched on certain facts and was fired, don't fire it again. The idea is to always do new things.</li>
</ul>
<p>There are quite a few other conflict resolution strategies, of course, but I've listed a few of the more common ones here. (We haven't really touched on domain specific conflict resolution strategies here.) You can chain these together, i.e. salience first, then, if you have several rules of the same salience, pick the longest matching one, etc.. The important point is that different resolution strategies can result in rules being fired in a different order. A change is some facts can result in some rules that were matched early on, but passed over by the conflict resolution strategy, not being executed at all.</p>
<p>Now you should probably write your rule-sets so that order of execution doesn't matter. But in practice, this ideal isn't the case. Often, rules are harvested from existing business processes where order is already enforced in some way.</p>
<p>While building rule-sets that are execution order independent is a good best practice, it isn't always practical. BRE's are complex systems with complex behaviors. Having different conflict resolution strategies is often necessary and desirable. I'm not proposing a silver bullet here to make all rule exection semantics the same, though it might be nice to make them more transparent and configurable. Just be aware that standards like JSR-94 are great for integration, but don't guarantee that you'll get the same results with those different engines. Understand the tools you use. </p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/07/conflict_resolu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JSR-94 - Getting Your Feet Wet</title>
		<link>http://www.pathf.com/blogs/2006/07/jsr94_getting_y/</link>
		<comments>http://www.pathf.com/blogs/2006/07/jsr94_getting_y/#comments</comments>
		<pubDate>Sat, 08 Jul 2006 03:08:11 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[JSR-94]]></category>

		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/07/jsr94_getting_y/</guid>
		<description><![CDATA[Over at the Sun Developer Network, you'll find a nice tutorial on writing a business rules application using JSR-94. It makes use of Jess rule engine for its example. What is JSR-94? From the tutorial: The specification for the Java...
]]></description>
			<content:encoded><![CDATA[<p>Over at the Sun Developer Network, you'll find a <a href="http://java.sun.com/developer/technicalArticles/J2SE/JavaRule.html?feed=JSC" target="_blank">nice tutorial</a> on writing a business rules application using JSR-94. It makes use of <a href="http://www.jessrules.com/" target="_blank">Jess rule engine</a> for its example.</p>
<p>What is JSR-94? From the tutorial:</p>
<blockquote><p>
The specification for the Java Rule Engine API (JSR 94), developed through the Java Community Process (JCP)<br />
program, defines a Java runtime API for rule engines by providing a<br />
simple API to access a rule engine from a Java Platform, Standard<br />
Edition (Java SE, formerly known as J2SE) or a Java Platform,<br />
Enterprise Edition (Java EE, formerly known as J2EE) Java technology<br />
client.</p>
</blockquote>
<p>Beyond being useful in that the JSR-94 allows you to interface with any rule engine that supports the standard, it's also useful from a pure code reading perspective. Rule-based systems are different from OO and procedural systems; you have to think and design the applications differently. Reading the Java code of the example should give anyone who has never written a rule-based application a practical understanding of how these things should be built.</p>
<p>Give it a look and study the code. Of course, the standard doesn't solve all of your problems. While it does allow you to write one set of Java code to interface with any compliant rule engine, not all rule engines behave the same. More on that later.</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/07/jsr94_getting_y/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Business Rules Management and Testing - Avoid the &#8220;Mystery Box&#8221;</title>
		<link>http://www.pathf.com/blogs/2006/06/business_rules__1/</link>
		<comments>http://www.pathf.com/blogs/2006/06/business_rules__1/#comments</comments>
		<pubDate>Fri, 30 Jun 2006 20:12:45 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/06/business_rules__1/</guid>
		<description><![CDATA[I apologize for being tardy this week with my post. The truth is that I just got my hot little hands on the latest Blaze Advisor with the new RETE III engine and have been heads down testing it out....
]]></description>
			<content:encoded><![CDATA[<p>I apologize for being tardy this week with my post. The truth is that I just got my hot little hands on the latest Blaze Advisor with the new RETE III engine and have been heads down testing it out. It's too soon for me to really say much about it other than "it's fast." Man is it fast. That's not a benchmark, mind you, just an impression from years of working with rule engines. OK, more on Blaze later.</p>
<p>OK, so over on The Road Hits the Rubber, Peter Lin <a href="http://woolfel.blogspot.com/2006/06/random-thoughts-on-rule-management.html" target="_blank">muses on the shortcomings of Business Rule Management Systems</a>:</p>
<ul>
<li><em>many users have very specific ideas about how to manage rules, but most don't bother using it. This applies to products from iLog to other vendors.</em></li>
<li><em>users who actually manage rules actively have very specific ideas about how it should work. In this case, existing tools don't match what they want.</em></li>
<li><em>an all purpose rule management system must be extensible for it to be useful. I'll go into this in greater detail</em></li>
<li><em>many companies using rule engines and business rules have poor process in place. the typical horror story is the business analysts deploy a rule without testing it and the production system crashes. It's frightening how many companies do this.</em></li>
<li><em>many business currently using rule engines are not using RETE algorithm and actually don't bother running compliance due to performance. this is actually very common and many businesses use performance as an excuse not to run compliance.</em></li>
</ul>
<p>Here, here. Many companies look at the BRMS offerings of their vendor and say "we don't work like that." Rules end up being dumped out into an export format and checked into a source code repository. This is no way to manage rules.</p>
<p>Peter suggests a number of solutions to the above problems. There's lots to digg into here but I'd like to focus on one thing and take issue with him a little bit. The last two points on testing and compliance are, in my opinion, a very important part of what a BRMS should deal with. Peter doesn't agree:</p>
<blockquote>
<p><em>Many sales guy ask for features like rule validation, spell checking and all sorts of stuff, but that isn't part of managing rules. That's the authoring of rules. To me authoring rules includes things like validation, profiling and application testing. Managing rules is a different discipline than writing rules, so it's best to separate the two activities and provide a clear integration between the two. When an user wants to save a draft of the rule, it sends the draft to the BRMS. If someone like his supervisor wants to review the rule, he should be able download it from the BRMS server.</em></p>
</blockquote>
<p>From my experience, you are managing rule sets, not just individual rules. If you write your tests and run your validations at rule authoring time, you are vulnerable to someone deploying an invalid or nonsensical rule subset to a production system. Rule set validation and regression testing should thus absolutely be a part of the BRMS; adding, subtracting or modifying a rule into a large system can have many unforeseen consequences and unit and regression testing of rules and rule sets is one excellent way of addressing this problem.</p>
<p>Maybe I misunderstand what Peter means here by validation. I take it to mean that you are checking an entire rule set for correctness within a context; that context may be a particular dataset or a particular set of tests. A rule set that is correct for a population of Medicare patients may not be correct for a set of Medicaid patients. Thus the tests you perform on a rule set are specific to where you are deploying that set.</p>
<p>Taking a page from the OO world, writing unit and regression tests and testing for code/rule coverage should be built into the BR system life cycle. If you are authoring a new rule, you are likely doing so to change the behavior of the system. You should have a clear idea of what that change consists of and how it would be expressed in a test case or regression test. Otherwise, if you can't specify what sort of change in behavior you are trying to achieve, you have no business modify the BR System to begin with.</p>
<p>Lack of aggressive and rigorous testing in rule management leads to what I've termed the "Mystery Box." This is the rule based system whose inner workings are so mysterious that no one can tell how it arrives at it's conclusions or whether those conclusions are correct. Imagine a company where fixes in data quality or rule set correctness would result in newly correct behavior for a rule-based system; they would face a crisis because they had been feeding their customers incorrect information for years. Don't let the "Mystery Box" happen to you.</p>
<p class="zoundry_bw_tags">  <!-- Tag links generated by Zoundry Blog Writer. Do not manually edit. http://www.zoundry.com -->  <span class="ztags"><span class="ztagspace">Technorati</span> : <a href="http://technorati.com/tag/bre" class="ztag" rel="tag">bre</a>, <a href="http://technorati.com/tag/brms" class="ztag" rel="tag">brms</a>, <a href="http://technorati.com/tag/business%20rules" class="ztag" rel="tag">business rules</a>, <a href="http://technorati.com/tag/business%20rules%20engine" class="ztag" rel="tag">business rules engine</a>, <a href="http://technorati.com/tag/rule%20management" class="ztag" rel="tag">rule management</a></span></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/06/business_rules__1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Business Rules Resources</title>
		<link>http://www.pathf.com/blogs/2006/06/business_rules_/</link>
		<comments>http://www.pathf.com/blogs/2006/06/business_rules_/#comments</comments>
		<pubDate>Tue, 20 Jun 2006 14:00:00 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/06/business_rules_/</guid>
		<description><![CDATA[I suppose everyone needs a link post -- how else to cross-pollinate all of the useful BRE resources out there? So here, in no particular order, is my contribution to spreading the news: The Java Business Rules Community - Periodic...
]]></description>
			<content:encoded><![CDATA[<p>I suppose everyone needs a link post -- how else to cross-pollinate all of the useful BRE resources out there? So here, in no particular order, is my contribution to spreading the news:</p>
<ul>
<li><a href="http://www.javarules.org/">The Java Business Rules Community</a> - Periodic announcements, links, and other materials of interest to BRE practitioners, especially those dealing with Java. Has turned into a bit of a press release haven of late.</li>
<li><a href="http://woolfel.blogspot.com/">The Road Hits the Rubber</a> - Peter Lin, the developer of the Sumatra rule engine, blogs relentlessly on BRE's, takes on sacred cows and explains complicated topics.</li>
<li><a href="http://brcommunity.com/">BRCommunity.com</a> - Web site of Business Rules Journal, a publication focused on explaining Business Rules and promoting the adoption Business Rule systems. Decent articles articles and resources, but maybe not as interesting for the technical practitioner. Requires free registration to access resources.</li>
<li><a href="http://www.businessrulesgroup.org/">Business Rules Group</a> - &quot;A non-commercial peer group of IT professionals...&quot;, two white papers, links to BR companies and event announcements.</li>
<li><a href="http://aai-rules.blogspot.com/">Down to Earth Business Rules</a> - The Artemis Alliance, Inc.'s eminently readable blog. Based on the experience of practitioners, some sample topics include &quot;Pitfalls and Lessons Learned of Business Rules Implementation - A Business Analyst Perspective Perspective,&quot; &quot;Decision Tables and Trees,&quot; and &quot;BEST PRACTICE.&quot; Well worth a read, though I wish they would publish more often.</li>
<li><a href="http://edmblog.fairisaac.com/">Enterprise Decision Management</a> - James Taylor blogs on Enterprise Decision Management (EDM), an area that includes BRE's. (Just think of all the mistakes you could have avoided if you'd had an EDM tool instead of a simple Pro vs Con legal pad.) Yes, he works for Fair Isaac and some of his posts talk about their products, but his blog is much more than a marketing vehicle. Well worth a read.</li>
<li><a href="http://groups.yahoo.com/group/bizrules/">bizrules</a> - Yahoo group. Really has ground to a halt. I wonder if this is because all of the participants are busy working on client engagements? Still, some of the old discussions are worth reading.</li>
<li><a href="http://www.jboss.com/products/rules">JBoss Rules</a> - New site for the old Drools, the Open Source Java RETE engine. Somehow the Drools.NET seems to have disappeared, but the Wiki, documentation and so on make this a great place to experiment with a commercial-quality RETE-based BRE.</li>
<li><a href="http://pluralsight.com/blogs/jeffsch/">Jeffrey Schlimmer's Blog at Pluralsight</a> - A newcomer to the world of BRE blogs, he gives some good comment nonetheless.</li>
<li><a href="http://www.agilepartner.net/oss/nxbre/">NxBRE</a> - Not RETE is what everyone says. But if you want to experiment with an Open Source BRE for .NET, this is the only one for now.</li>
<li><a href="http://www.manageability.org/blog/stuff/rule_engines/view">Manageability.org</a> - the popular Java blogs list of Java Open Source BRE's. This is always my starting point when I look for anything Java and Open Source.</li>
<li><a href="http://www.bizrules.info/blog/">Bizrules</a> - Rolando Hernandez, a consultant for Miami, shares his thoughts on Business Rules. I don't always agree with him, but I find his posts well thought out and engaging.</li>
<li><a href="http://www.squidoo.com/businessrules">Squidoo Business Rules</a> - A big list of resources, much more exhaustive than my own and much better organized.</li>
</ul>
<p>If I've left any out, feel free to leave them in the comments.</p>
<p>&nbsp; </p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/06/business_rules_/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Misunderstood Decision Table</title>
		<link>http://www.pathf.com/blogs/2006/06/the_misundersto/</link>
		<comments>http://www.pathf.com/blogs/2006/06/the_misundersto/#comments</comments>
		<pubDate>Tue, 13 Jun 2006 14:00:00 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/06/the_misundersto/</guid>
		<description><![CDATA[Pity the poor Decision Table. It and its close relative, the Decision Tree, are much maligned in the world of Business Rules Engines. They are slow, awkward, unattractive, unsuitable for all but the most primitive and useless of problems. Clearly...
]]></description>
			<content:encoded><![CDATA[<p>Pity the poor Decision Table. It and its close relative, the Decision Tree, are much maligned in the world of Business Rules Engines. They are slow, awkward, unattractive, unsuitable for all but the most primitive and useless of problems. Clearly RETE is superior, for it allows you to throw your facts and rules into a cauldron and magically and instantly come up with results. Only losers use decision tables.</p>
<p>Of course this view is far from the truth and relies on both a misunderstanding of what problem the RETE algorithm tries to solve and a straw man decision table implementation. First to the question of what problem the RETE algorithm tries to solve. From Forgy's original paper:</p>
<blockquote><p>A pattern matcher can avoid iterating over the elements in working memory by storing information between cycles. The step that can require iteration is determining whether a given pattern matches any of the working memory elements. The simplest interpreters determine this by comparing the pattern to the elements one by one. The iteration can be avoided by storing, with each pattern, a list of the elements that it matches. The lists are updated when working memory changes. When an element enters working memory, the interpreter finds all the patterns that match it and adds it to their lists. When an element leaves working memory, the interpreter again finds all the patterns that match it and deletes it from their lists.</p>
</blockquote>
<blockquote><p>Since pattern matchers using the Rete algorithm save this kind of information, they never have to examine working memory.</p>
</blockquote>
<p>To summarize, if you want to match (or unmatch) new rules when the facts change, you don't want to reevaluate the whole shootin' match. The RETE algorithm does this efficiently. But what if <a href="http://blogs.pathf.com/business_rules/2006/04/do_you_really_n.html">you don't need to match rules when the facts change</a>? In that case, all this saving of information may be just a bunch of overhead. </p>
<p>Next to the question of the straw man: when most writers discuss the decision table, they describe a n-dimensional table with discrete and finite dimensions and cells that contain &quot;actions.&quot; They also tend to imply a certain execution algorithm, as <a href="http://aai-rules.blogspot.com/2006/03/decision-tables-and-trees.html">this article</a> does:</p>
<blockquote><p>The decision table is a very familiar decisioning structure. Price<br />
lists, bus , and train schedules are often represented as a table and<br />
function very similarly to a decision table. For example, given your<br />
current location (input parameter 1) and where you want to go ( input<br />
parameter 2), the table will tell you when the train will arrive (your<br />
outcome). At a most basic level, two different parameters are<br />
represented along the axis of the table in columns and rows. The<br />
intersections of the two axes constitute the decision point for the<br />
given combination of parameter values.</p>
</blockquote>
<p>While the author doesn't explicitly say that this is how the implementation and execution of a decision table should proceed -- look up an entry in a multidimensional table -- it is implied. This gives the decision table short shrift. Just like the production system is an invention of the 1970's for which efficient algorithms were developed in the 1980's and 1990's, just so the decision table and tree are inventions of the 1950's for which efficient algorithms were developed in the 1960's and 1970's. These efficient algorithms don't look anything like the naive table look up.</p>
<p>Most of the efficient algorithms involve turning the &quot;extended&quot; decision table, which has multiple discrete values in a dimension, into a simple decision table, which has just true-false values in its dimensions. Then this simple decision table is typically converted into a different problem space which has more efficient solution algorithms. Depending on whether the goal is to optimize average or worst case execution time or memory consumption, the solution might involve converting the table into a decision tree.</p>
<p>Last, while decision tables and trees are typically used on an analytical level in current business rules practice -- business analysts decomposing a problem into a table or tree of actions -- IF-THEN rules can actually be converted into simple decision tables directly. When the efficient decision table algorithms are combined with other techniques like rule chaining, the result can be rather zippy systems for situations where inferencing is not necessary or the numbers of rules and facts are small.</p>
<p>I hope I've convinced you of the decision table's continued viability. The next time someone scoffs at the decision table, please say a kind word in its defense.  </p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/06/the_misundersto/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Prova - Son of Mandarax (Backward Chaining Rule Engines)</title>
		<link>http://www.pathf.com/blogs/2006/06/prova_son_of_ma/</link>
		<comments>http://www.pathf.com/blogs/2006/06/prova_son_of_ma/#comments</comments>
		<pubDate>Wed, 07 Jun 2006 14:00:00 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
		
		<category><![CDATA[Business Rules]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/2006/06/prova_son_of_ma/</guid>
		<description><![CDATA[When development of the open source backward chaining rule engine Mandarax halted some time in early 2005, I thought that it had become yet another tombstone in the cemetary of abandoned one-man open source projects. A real shame, since Jens...
]]></description>
			<content:encoded><![CDATA[<p>When development of the open source backward chaining rule engine <a href="http://mandarax.sourceforge.net/">Mandarax</a> halted some time in early 2005, I thought that it had become yet another tombstone in the cemetary of abandoned one-man open source projects. A real shame, since <a href="http://www-ist.massey.ac.nz/JBDietrich/">Jens Dietrich</a>'s Java-based tool supported RuleML, had a GUI environment (<a href="http://sourceforge.net/projects/oryx">Oryx</a>) and was probably the most polished backward chaining rule engine out there.</p>
<p>So I was very pleased when a friend notified me of another phenomenon that sometimes happens in the open source world: Mandarax had been adopted by a new community of developers. The new project is known as <a href="http://www.prova.ws/">Prova</a>. From their website:</p>
<blockquote><p>Prova is derived from<br />
Mandarax Java-based inference system developed by Jens<br />
Dietrich. Prova extends Mandarax by providing a proper language<br />
syntax, native syntax integration with Java, and agent messaging<br />
and reaction rules. The development of this<br />
language was supported by the grant provided within the EU projects<br />
GeneStream and BioGRID. In the project, the language is used as<br />
a rules-based backbone for distributed web applications in biomedical data<br />
integration, in particular, the<br />
GoPubMed system.</p>
</blockquote>
<p>The software is under active development and even has an alpha Eclipse plugin (you need to check it out and build it yourself, though).</p>
<p>What does a simple Prova application look like? Well, Prova allows you to integrate it in a number of ways, including as a JMS listener. Let me give you a flavor of &quot;Hello World!&quot; with Prova embedded in a Java app:<span style="font-family: monospace;"><span style="text-decoration: underline;"><br /></span></span></p>
<p><a href="http://blogs.pathf.com/business_rules/files/prova.txt">Download prova.txt</a></p>
<p><span style="font-family: monospace;"><span style="text-decoration: underline;">&nbsp;</span></span></p>
<p>Why do I get so excercised about backward chaining engines? Well, I do a bit of work in evidence based medicine. In that context it isn't enough to simply know that a certain conclusion has been reached or that a certain sequence of rules has been fired. I need to know ALL of the ways in which a conclusion has been reached. This can be done in a forward chaining rule engine, but the builtin support just isn't there.</p>
<p>Unfortunately, this support, while there in Mandarax, seems to have disappeared in Prova (calling getProof() on the resultset returns null). Once the 1.9 release is out, the developers have said they will reintroduce derivation support.</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder is a software development firm. Hire us to build complex software that's easy to use.</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2006/06/prova_son_of_ma/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
