I’d like to share a little story from our recent consulting experience. Being in the midst of helping our client to deliver a large OpenRules-based banking system, we received an urgent request. The problem should be familiar to many businesses who deal with NAICS (the North American Industry Classification System). In our case, a client maintained one large Excel table that maps NAICS codes to different business activities. It looked as below:
The actual table had more than 1,000 rows with codes and 30+ columns with different business categories. The request was relatively simple:
having a Java object “Customer” with a known NAICS code, we need to use the above table to define all business categories for this customer.
However, it came late in the evening and they needed a working solution in the morning!
Under time pressure, we considered two choices:
- Convert this table into a similar OpenRules Data table (also in Excel), read it into a Java collection using an existing instance of the OpenRulesEngine, and then write a simple Java method that will iterate through this collection by adding matched customer’s categories.
- Convert this table into a similar Rules table without writing new Java classes and methods.
We selected a more elegant second solution. We simply added the following 4 lines on the top of the existing table:
It effectively converted our initial table into an executable single-hit Rules table. Here is how it works. The condition C1
simply compares a customer’s code with NAICS codes from the table, and when the first match is found, it executes all actions (marked as “x”) from the same row. The actions A2, A3, A4, … are written as below:
This Java snippet simply adds categories whose names are defined in the column titles – here we took an advantage of the predefined OpenRules macro $COLUMN_TITLE.
That was it! No further coding were required. No other changes in the initial NAICS table.
Conclusion. Of course, I could share examples of mush more complex problems addressed by OpenRules. But for me personally, a little story like this one is an another proof of the OpenRules maturity: over the years our product became a practical foundation for finding simple and elegant solutions for complex real-world decision management problems. Such solutions are usually governed by business analysts and are naturally integrated with the existing software.