Rule Engines don’t serve only the dynamic programming. They evaluate rules and extract some inferences by using some algorithms like RETE. This inference mechanism is hardly possible with many “if-else” statements in normal program code. Rule Engines have generally 4 types of rules;
We can use Rule Engines on the market but even we can write our own Rule Engine to benefit the dynamic programming in Java. By using Java compilers, classloaders, it is not so much hard. My favorite rule definition format is Java source code instead of some natural languages or XML. This can also reduce the overall development cost of your custom rule engine. By writing Java rule definitions, we can also use the IDE debugger features without learning a new syntax. If we develop our own Rule Engine, we may skip the inference engine part since we only want dynamic programming feature for now. Best place for plugging rule execution is database access layer. Rules should work invisibly behind the database objects. In some cases, some rules might be invoked from static program codes.
The benefits that we have when using Rule Engine are:
Some of the features of Rule Engine may remind us database constraints and triggers. Using database may hinder portability and require DBA involvement. I think Rule Engine is better for business rule definitions. These database features may be used for other purposes.
The critical question we should ask ourselves is which part of business rules should be taken into Rule Engine from the programs. The answer is “frequently changing” rules. Some changing parts can be defined within parameter tables (processing options) but we can’t define computation or many if-else statements in these tables. But we should prefer parameter table if it is enough for the problem.
Links:
http://java.sun.com/developer/technicalArticles/J2SE/JavaRule.html
http://www.javaworld.com/javaworld/jw-04-2005/jw-0425-ruleengine.html
http://www.javaworld.com/javaworld/jw-06-2006/jw-0612-dynamic.html
http://www.amazon.com/Principles-Business-Addison-Wesley-Information-Technology/dp/0201788934/ref=sr_1_3?ie=UTF8&s=books&qid=1236927606&sr=1-3
http://www.amazon.com/Business-Rules-Applied-Building-Approach/dp/0471412937/ref=sr_1_1?ie=UTF8&s=books&qid=1236927606&sr=1-1
2 comments:
I think there is an inconsistency about your advices. You talk about business rules and you advice to put them at the data access layer level. Data access layer is a technical level, I think rules should be more appropriate at the service level, where the business logic stands.
OK, no matter, it may depend on your development environment/context where you plug it. IMHO, the important thing here is that it should work invisibly behind the running code that altering rules should be smoothly reflected to the runtime without any webapp restart. In our context, we bind rules with application or database objects thus it provided us rule filtering as well. In this way, we could determine which rules would work at which operation. If you can achieve this in service level there is no problem at all.
Post a Comment