[TECH] Rules Engine - Drool

Implement business logic with the Drools rules engine

Use a declarative programming approach to write your program's business logic

Using a rules engine can lower an application's maintenance and extensibility costs by reducing the complexity of components that implement complex business logic. This updated article shows you how to use the open source Drools rules engine to make a Java™ application more adaptive to changes. The Drools project has introduced a new native rule expression language and an Eclipse plug-in, making Drools easier to use than ever before.

Most of the complexities that requirements impose on today's software products are behavioral and functional, resulting in component implementations with complex business logic. The most common way to implement the business logic in a J2EE or J2SE application is to write Java code that realizes the requirements document's rules and logic. In most cases, this code's intricacy and complexity makes maintaining and updating the application's business logic a daunting task, even for experienced developers. And any change, however simple, incurs recompilation and redeployment costs.

A rules engine helps you resolve (or at least reduce) the issues and difficulties inherent in the development and maintenance of an application's business logic. You can think of a rules engine as a framework for implementing complex business logic. Most rules engines let you use declarative programming to express the consequences that are valid given some information or knowledge. You can concentrate on facts that are known to be true and their associated outcomes — that is, on an application's business logic.

Several rules engines are available, including commercial and open source choices. Commercial rules engines usually let you express rules in a proprietary English-like language. Others let you write rules using scripting languages such as Groovy or Python. This updated article introduces you to the Drools engine and uses a sample program to help you understand how to use Drools as part of your business logic

Drools is an open source rules engine, written in the Java language, that uses the Rete algorithm to evaluate the rules you write (see Resources). Drools lets you express your business logic rules in a declarative way. You can write rules using a non-XML native language that is quite easy to learn and understand. And you can embed Java code directly in a rules file, which makes the experience of learning Drools even more attractive. Drools also has other advantages. It is:

  • Supported by an active community
  • Easy to use
  • Quick to execute
  • Gaining popularity among Java developers
  • Compliant with the Java Rule Engine API (JSR 94) (see Resources)
  • Free

http://www.ibm.com/developerworks/java/library/j-drools/

Reference Sites:

0 replies: