- Blog Xebia France - -

Posted By Nicolas Lecoz One on Friday, January 8th, 2010 18:09 In Java 3 Comments

When they hear about engine of rules, they often have tendency to link to it word " Drools  .

Why this reflex:

  • By habit?
  • Because Drools is the only solution of the market Open Source?

But before I would like to answer several questions:

  • What an engine of rules?
  • When do they need it?
  • Why do they need it?

Then it will be possible to introduce Drools!

What an engine of rules, and why?

Seen outside, an engine of rules is a system capable of defining rules and of applying them to facts. By popularising, a fact is data.
An engine of rules is ideal solution for programmes containing a logic requiring a significant number of "yew tree" (i.e. potentially detectable with a tool of analysis of the quality of code, in rubric cyclomatique complexity).

By looking under the bonnet, an engine of rules is more complex. Rules and facts are injected in an engine of inference. This engine of inference searches rules applicable to facts (pattern matching). Everything takes place in memory. That is that the rule has the same cycle of life as data. A rule can be loaded, unloaded or changed in memory without r initialisation of the engine of rules. Then, the engine of rules optimises the execution of rules by ranking them in a most efficient possible way (agenda).

drools engine of regles

An engine of rules allows therefore to isolate the treatment (rules), of data (facts). Furthermore he allows for example to manage algorithms with many microcomputings rules which often change. Ideal, therefore for algorithms implementing a commercial, very variable logic according to requests of the marketing teams. Here is a case of possible use for a site of ecommerce of sale of fruits and vegetables: an algorithm job which calculates the complete price of an order, a sconce of promotions according to many conditions on the basket and the chip client.

Presentation

To Xebia, every first Thursday of every month, there is XKE (Xebia Knowledge Exchange). It occasions all consultants of Xebia to meet all together to share on various technical subjects or architecture which hold us in heart.

During XKE of December, I introduced a session on the engines of rules and the framework Drools (JBoss).

This presentation tackles several points:

  • What an engine of rules?
  • Drools, alternatives and his review.
  • Summary of a comparative of engine of rules.
  • First rule, a simple rule!
  • Legible rules for a human being (DSL and Table of decision).
  • ().
  • (Flow / WorkFlow).
  • (Blowhole Processing).
  • Performance:

Presentation was dense. Indeed, the focus was put on the last version of Drools, the version 5, who offers a tremendous number of functionality. Besides, it is a complex framework who asks for a long immersion several months to be autonomous on the product. Certainly, he offers to resolve not common problems in the world of the development of applications of management but the choice of such solution asks for a deepened study by taking into account different aspects:

  • Need of an engine of rules, a solution of simpler management of rules can be enough as for example the pattern Specification,
  • Cost and time:
    • of training of the developers
    • for the realisation of an archetype,
  • Performance,
  • Process of management of rules (who is going to manage configurer and rules).

According to me, the advantages of Drools are:

  • Resolution in an efficient way not classical algorithms.
  • The table of decision via a file Excel which is very close to a specification and so avoids a translation towards code not often nice to support.
  • Drools Guvnor, a Web application to manage and to change rules in heat via a graphic interface.
  • The integration of Drools can be only made on a particular point of application, for an algorithm for example. It will have no impact on the rest of the appplication.

Drools allows to manage rules via IHM thanks to the component Guvnor.

Creation of a rule with Guvnor



Modification of a rule with Guvnor


Management of a table of decision with Guvnor


Article printed from Blog Xebia France:

URL to article: / 2010 / 01 / 08 / drools-et-les-moteurs-de-regles /

Click here to print.