Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
JavaCro'14 - Continuous deployment tool – Aleksandar Dostić and Emir Džaferović
Next
Download to read offline and view in fullscreen.

Share

JavaCro'14 - Drools Decision tables – form of human-readable rules – Dragan Juričić

Download to read offline

Drools is a business rule management system (BRMS) with an inference based engine, using an enhanced implementation of the Rete algorithm. Business rules implementations are aimed mostly at developers. However, it is sometimes needed that these rules are readable and understandable by the business analysts. Ideally, they should be able to change rules or even write new ones. Decision table as a form of human-readable rules involve business analysts in creation and maintenance of rules.
Managing rules in a spreadsheet format is very applicable for business analysts since they already use them. An important aspect of business rules is their readability and user friendliness. Looking at a rule, you should immediately have an idea of what it is about.

Related Books

Free with a 30 day trial from Scribd

See all

JavaCro'14 - Drools Decision tables – form of human-readable rules – Dragan Juričić

  1. 1. Dragan Juričić, Privredna banka Zagreb
  2. 2. Introduction to “business rules” High level overview of JBoss Drools Decision tables Discussion of benefits and downsides
  3. 3. Business Rules
  4. 4. Basic problem: how to model “business logic” try to automate all kinds of business process process and decisions are not very well representded using traditional programing language such as Java or C# Drools – makes the process of implementing rules quicker and handles complexity
  5. 5. Rule engine is a piece of software, which having some knowledge is able to perform conclusions Type of Expert System Two types of rules: “Production (or Inference) Rules” If x, then y Often stateless “Reaction Rules” (Complex Event Processing) Wait for set of events Stateful
  6. 6. Rules consist of conditions and actions, which are executed when their conditions are true Conditions for above rule: Object type condition - Applicant Object Type Field condition - age < 18 Matching patterns against the inserted data 6 rule "Is of valid age" when $a : Applicant(age <18) Condition then $a.setValid( false); Action end public class Applicant { private String name; private int age; private boolean valid; //getter and setter methods }
  7. 7. 7 JBoss Drools
  8. 8. 8 “A common platform to model and govern the business logic of the enterprise.”
  9. 9. Core Drools product Has an enhanced and optimized implementation of the Rete algorithm for object oriented systems called as ReteOO Higher memory consumption for increased speed Forward chaining rule interpreter : “data driven” 9
  10. 10. Technical Rule Language (Drools Rule Language – DRL) mostly aimed for developers Human-readable rules Custom Domain Specific Languages (DSL) Guided Editor DecisionDecisionDecisionDecision TableTableTableTable XML 10
  11. 11. Decision Tables
  12. 12. Excel XLS based Tabular representation of decisions Compact way to model large sets of related rules 12
  13. 13. 13 rule "Interest Calculation_16" when $a:Account(type == Account.Type.SAVINGS, currency == "EUR", balance >= 100 && < 1000, monthsBetweenStartAndEndDate >= 1 && < 3) then $a.setInterestRate(new BigDecimal("3.00")); end
  14. 14. Advantages of a decision tables It is easy to read and understand Refactoring is quicker (change conditions across group of rules) Involve “business users” in creation & maintenance Many businesses already use spreadsheets for managing data Any formatting available in a spreadsheet editor can be applied Disadvantages of a decision table XLS is a binary format which makes version management more difficult It can be awkward to debug these rules 14
  15. 15. 15
  16. 16. 1 DecisionTableConfiguration dtableconfiguration = 2 KnowledgeBuilderFactory.newDecisionTableConfiguration(); 3 dtableconfiguration.setInputType(DecisionTableInputType.XLS); 4 dtableconfiguration.setWorksheetName("Tables"); 5 6 KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); 7 kbuilder.add(ResourceFactory.newClassPathResource("SearchCase.xls"), 8 ResourceType.DTABLE, dtableconfiguration); 9 10 if (kbuilder.hasErrors()) { 11 for (KnowledgeBuilderError err : kbuilder.getErrors()) { 12 System.out.println("Drools error: " + err.getMessage()); 13 } 14 } 15 KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); 16 kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); 17 18 StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(); 19 ksession.execute(Iterable p_objects); 16
  17. 17. Discussion
  18. 18. Large set of rules, with complex branching Rules likely to change over time, likely out of sync with code changes Involve “business users” in creation & maintenance of rules
  19. 19. Separates “business logic” from application code “Hot” changes of rules (no recompile) Improved performance for large rule sets Communicates rules more clearly than Java code
  20. 20. New tool Learning curve Extra point of failure Overhead Not practical for small rule sets
  21. 21. http://www.jboss.org/drools/ http://en.wikipedia.org/wiki/Drools http://docs.jboss.org/drools/release/5.5.0.Final/droolsjbpm- introduction-docs/html_single/index.html http://technicalmumbojumbo.wordpress.com/2009/03/28/jb oss-drools-decision-tables/ http://www.packtpub.com/article/human-readable-rules- with-drools-jboss-rules-part1 http://docs.jboss.org/drools/release/5.5.0.Final/droolsjbpm- introduction-docs/html_single/index.html 21
  • gordonwho

    Oct. 7, 2014

Drools is a business rule management system (BRMS) with an inference based engine, using an enhanced implementation of the Rete algorithm. Business rules implementations are aimed mostly at developers. However, it is sometimes needed that these rules are readable and understandable by the business analysts. Ideally, they should be able to change rules or even write new ones. Decision table as a form of human-readable rules involve business analysts in creation and maintenance of rules. Managing rules in a spreadsheet format is very applicable for business analysts since they already use them. An important aspect of business rules is their readability and user friendliness. Looking at a rule, you should immediately have an idea of what it is about.

Views

Total views

2,117

On Slideshare

0

From embeds

0

Number of embeds

1,384

Actions

Downloads

21

Shares

0

Comments

0

Likes

1

×