Remove/Cancel Bubbling for an Event in Flex3
I recently had an issue in flex where I needed the click event for a component in an ItemRenderer to not bubble up to the parent list. Since the click event was being dispatched by Flex SDK code, I could not directly do this by passing false into the event's constructor. I had hoped to find a property I could set on the object, something like "clickBubbles", which I could set which would accomplish this.
Either that property doesn't exist or I could not find it. My solution was to basically hijack the event and send an impersonator in its place.
Adopt a non-techie. Help your business team move faster

I've been spending some time with our internal sales and marketing team to hash out some of our goals for the year, and it became quite clear to me that non-developers are on their computers all day long facing some of the same technical challenges we do.
Some of the tasks they have to do:
- "take the data out of the spreadsheet for last quarter and compare it to this quarter"
- "gather the bounced emails from our newsletter posting, and update our list, pulling out duplicates"
- "replace all the names and addresses from our NDA agreement each time it is sent to a new client"
- "slice and dice google ad-words and google analytics data"
So I've resolved to take some time each week to 'Adopt a non-techie', and help them spend less time 'screwing around with the computer' and more time on the most valuable tasks they do.
In the same way that developers need to be as efficient as possible with the tools they use, Continue reading »
Topics: agile, google docs, imacros, neal ford, nfjs, Pair Programming, portableapps, productive programer, regex, regular expressions, Selenium, ubuntu, xp
ILog Aquired by IBM
I've used the ILog Business Rules products on a number of projects. Reasonable software. Does the job. Not exactly cheap. I'm not sure why they went for the aquisition by IBM -- it was announced back at the end of July, so likely nothing to do with hard economic times.
What does this mean for software developers and system integrators? Back when the aquisition plans were first announced, I joked that we would soon be using WebSphere rules. And wouldn't you know it, the aquisition announcement mentions ILog and WebSphere in the same sentence several times.
Topics: Business Rules, IBM, ILog, ILOG JRules, Oracle
Category and UI changes on Pathfinder blogs
If you read one or more of the Pathfinder blogs in our web interface, you may have noticed some tweaks to our navigation and top-level categories. Our goal in making these changes was to help different audiences drill down to the specific content that interests them. Instead of just a few top-level categories, we now boast around 20, though many posts appear in multiple categories. To subscribe via RSS to any specific category - or to our entire feed - just visit our Feeds page.
Topics: news
GWT Showcase - BRMS for JBoss Rules
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 called RETE, from the ancient Greek for "net"). For more on BRE's and how to use them, have a look at our Business Rules blog.
One of the things that has differentiated commercial BRE's like Blaze Advisor and ILOG JRules 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 (BRMS) -- that made their use in a corporate IT "ecosystem" much easier.
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.
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.
Compare this with a framework like Echo2/3 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.
Topics: Blaze Advisor, Business Rules, GWT, ILOG JRules, RETE
The Blogs Have Moved
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 all of the sub-blogs individually through their feeds and category pages.
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 info@pathf.com.
Topics: Announcement
Something to watch: Ruleby, a Ruby RETE Implementation
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 now. I'll post a couple of examples in it in the next couple of weeks.
Technorati Tags: bre, ruby, rails, rete, rools, SIE, Ruleby
Topics: Business Rules, RETE
BRE Patterns III: Collaboration Cop, Part II
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 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).
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.
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 Why getter and setter methods are evil and other Edsger Dijkstra-like articles) has identified the "procedural boundary layer" and explains it nicely in his book Holub on Patterns: Learning Design Patterns by Looking at Code:
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.
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.
As an example why you need to expose all object, consider an order that is made up of line items.
public interface Order {
[...]
void addItem(OrderLineItem item);
boolean removeItem(OrderLineItem item);
[...]
}
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.
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.
Another approach is to wrap the domain objects in bean containers that access the private instance variables through reflection.
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.
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.
Topics: Business Rules, Patterns
Will JBoss Rules 3.1 Do for BRE’s What mySQL Did for RDBMS’?
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 3.1 M1 drop contains operations on collections:
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 > 9) from collect ( HackEvent(hackType == HackEvent.PORT_SCAN, $date : eventDate -> (DateHelper.withinDayWindow($crash.getEventDate(), $date, 1)))) then suspicious.add($crash); end
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 here. 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.
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.
A few nits that I'm sure the JBoss Rules team will work out:
- 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.
- 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 this mod 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.
- A real-time audit view to inspect engine events would be handy.
- 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.
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.
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.
Topics: Business Rules, Drools, JBoss Rules
BRE Patterns III: Collaboration Cop, Part I
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.
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 works by Ross.
Pattern Name: Collaboration Cop
Synopsis
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.
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 Use Case. 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).
Context
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):
customer.addRental(new Rental(title.getTape()));
The customer 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.
In the Collaboration Cop version we would create an event and insert it into the working memory:
VideoStoreEvent event = new VideoStoreEvent();
event.type = VideoStoreEvent.RENT_TAPE;
event.value = "Gone With the Wind";
IF event.type == VideoStoreEvent.RENT_TAPE AND title.getTitle() == event.value AND title.isInStock()
AND customer.activeRentals() < 3
THEN
customer.addRental(new Rental(title.getTape()));
externalObjectSet.add(customer);
externalResponse.message = "Rented tape.";
externalResponse.success = true;
ELSE
externalResponse.message = "Unable to rent tape.";
externalResponse.success = false;
You can wrap a transaction around the sequence of event injections, then save (using an ORM) all of the modified objects in the externalObjectSet.
-----------
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.
Topics: Business Rules, Patterns
Resources and Announcements
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.
The first is Pychinko, 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.
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 Real-World Rule Engines. The article covers quite a bit of territory. Among the topics addressed are:
- What are rule engines
- How do you use them
- Architecting with Rule Engines
- Managing Rules
- Rule Engine Patterns and Anti-Patterns
- Governance
- Thoughts on rule writing
Definitely a good resource for those wanting to get started with business rules engines.
Last, I wanted to pass on the news that James Taylor has moved his blog over to a new url: http://www.edmblog.com/weblog. 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.
Topics: RETE
JBoss Rules Wiki - A Business Rules Community of Practice
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
Topics: Drools, JBoss Rules, Patterns
A Performance Comparison of Jess, Drools and MS-BRE
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 Microsoft's Rule Engine Scalability Results - A comparison with Jess and Drools. 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.
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 firm believer 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.
Topics: Benchmarking, Business Rules, Drools, JBoss Rules, Jess
OpenCyc 1.0 Released
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 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&D in academia and industry) and then OpenCyc.
What is included with the first release of OpenCyc?
Release 1.0 of OpenCyc will include the following:
- 6,000 concepts: an upper ontology for all of human consensus reality.
- 60,000 assertions about the 6,000 concepts, interrelating them, constraining them, in effect (partially) defining them.
- A compiled version of the Cyc Inference Engine and the Cyc Knowledge Base Browser.
- 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.
- 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.
- A specification of CycL, the language in which Cyc (and hence OpenCyc) is written. There are CycL-to-Lisp, CycL-to-C, etc. translators.
- 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.
- A few sample programs that demonstrate use of the Cyc API for application development.
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.
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.
Update 1: There are some comments that give a little bit more texture on Cyc from a IEEE mailing list.
Topics: Open Source
Is a BRE Turing Complete?
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 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.
Turing Complete
First the easy question: when is a system Turing Complete? From the Wikipedia:
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.
So, what is a Turing machine? Again you can look at the Wikipedia, 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."
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 von Neuman 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.
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 Finit State Machine, basically the most primite of the interesting algorithms. But in principle, a BRE with infinite memory is Turing Complete.
First Order Logic
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 for all facts of a particular type in our fact base or which are true for at least one fact. I've written before 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.
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.
About Pathfinder
Follow the Blog
-
Get a monthly update on best practices for delivering successful software.
Subscribe via email
Subscribe via RSS
Categories
Topics
Archives
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
Blogroll
Recent
- Aesthetics and Web Design
- Asterisk-Java Testing with Groovy
- 3 Misuses of Code Comments
- Fluently NHibernate
- Digging a Hole and Covering it with Leaves — The Software Development Version
- The Importance of User Experience - Do You Understand It in Your Bones?
- Writing Your Own Protocol With NSURLProtocol
- What’s In Your Dock: iPhone edition
- Feature Fatigue
- ChicagoRuby meeting ‘Test Prescriptions’ recap


