Book Image

JBoss Drools Business Rules

By : Paul Browne
Book Image

JBoss Drools Business Rules

By: Paul Browne

Overview of this book

<p>In business, a lot of actions are trigged by rules: "Order more ice cream when the stock is below 100 units and temperature is above 25&deg; C", "Approve credit card application when the credit background check is OK, past relationship with the customer is profitable, and identity is confirmed", and so on. Traditional computer programming languages make it difficult to translate this "natural language" into a software program. But JBoss Rules (also known as Drools) enables anybody with basic IT skills and an understanding of the business to turn statements such as these into running computer code.<br /><br />This book will teach you to specify business rules using JBoss Drools, and then put them into action in your business. You will be able to create rules that trigger actions and decisions, based on data that comes from a variety of sources and departments right across your business. Regardless of the size of your business, you can make your processes more effective and manageable by adopting JBoss Rules.<br /><br />Banks use business rules to process your mortgage (home loan) application, and to manage the process through each step (initial indication of amount available, actual application, approval of the total according to strict rules regarding the amount of income, house value, previous repayment record, swapping title deeds, and so on).<br /><br />Countries such as Australia apply business rules to visa applications (when you want to go and live there)&mdash;you get points for your age, whether you have a degree or masters, your occupation, any family members in the country, and a variety of other factors.<br /><br />Supermarkets apply business rules to what stock they should have on their shelves and where&mdash;this depends upon analyzing factors such as how much shelf space there is, what location the supermarket is in, what people have bought the week before, the weather forecast for next week (for example, ice cream in hot weather), and what discounts the manufacturers are giving.<br /><br />This book shows how you can use similar rules and processes in your business or organization. It begins with a detailed, clear explanation of business rules and how JBoss Rules supports them.<br /><br />You will then see how to install and get to grips with the essential software required to use JBoss Rules. Once you have mastered the basic tools, you will learn how to build practical and effective of the business rule systems.<br /><br />The book provides clear explanations of business rule jargon. You will learn how to work with Decision Tables, Domain-Specifi c Languages (DSL)s, the Guvnor and JBoss Integrated Development Environment (IDE), workflow and much more.<br /><br />By the end of the book you will know exactly how to harness the power of JBoss Rules in your business.</p>
Table of Contents (18 chapters)
JBoss Drools Business Rules
Credits
Foreword
About the author
About the reviewer
Preface
6
More rules in the JBoss IDE

Life or death business rules


The health services in Bangladesh (like many elsewhere) can't get enough doctors. Training more doctors is not an answer. Those who do qualify tend to leave for higher rates of pay elsewhere. So, given the desperate need for trained medical staff in rural areas (for example, to curb child mortality rates), what are the health workers to do?

The more qualified a doctor is, the more likely he is to take a flight. The district hospital in Matlab, Bangladesh, boasts an operating table, lamp, oxygen cylinder, and anesthetic machine, all carrying the EU's gift tag. They gleam, partly because they are unused. Several surgeons and anesthetists have been trained, but none so far have been retained. "Other than holding a gun to their head, doctors do not stay here.", comments Shams Arifeen, a researcher in the International Centre for Diarrhoeal Disease Research, Bangladesh (ICDDR, B). Doubling their pay is not the answer because they can earn five or ten times as much in private practice. Besides, specialists want to educate their children in the capital Dhaka, not in Bangladesh's backwaters.

What would you do?

Imagine that you were standing in that clinic without medical training, when a mother asks you to look at her sick child. What will you do? The solution that the Bangladesh health workers came up with was IMCI or Integrated Management of Childhood Illness. IMCI takes the knowledge in a doctor's head and writes it down as a set of rules that health workers can follow. When a sick child is brought into the remote clinic, the health worker is able to follow the simple step-by-step instructions to make quite a sophisticated diagnosis.

The following figure shows IMCI:

Look at the boxes in the above diagram—it's a set of medical rules. (Source, World Health Organisation, http://whqlibdoc.who.int/publications/2005/9241546441.pdf.) Using these rules a health care worker can quickly come to the following conclusions:

  • When the child is under two years of age, then refer to doctor immediately

  • When the child's skin does not bounce back when pinched, then the child is dehydrated

  • When the child is dehydrated then give rehydration salts

This is a real life example of business rules. Although it is paper-based and useful to the medical profession, it's a good example of business rules all the same.

  • Rules are 'when something is present, then do this'. And not just single rules, but many of them. Together, loads of simple rules allow you to come up with quite a sophisticated diagnosis.

  • Ruleflow and Workflow allow you to group your rules and decide which should fire first. If you're a health worker with a sick child, you want to do the most important checks first. Depending on the outcome, you then apply the next set of medical rules.

Everybody, including the doctors, is happy that his or her knowledge has been translated into rules. The doctors are happy because they can (guiltlessly) move to better-paying jobs. The medical workers using the system are happy because they can help the sick children that they see every day. The children gain because the better availability of medical knowledge is literally the difference between life and death.

Note

If you've used a computer language before, you might find the above example strange. 'Traditional' computer languages are more like a set of instructions: Do step 1, do step 2, repeat 5 times, and so on. Rules are different; they allow you to make many individual statements of what you know to be true and then let the computer decide if these rules apply (or not) to the current situation. This is similar to the way in which the human mind works.

Look again at the example. We don't specify any order for our rules. All of them, one of them, or none of them might apply in a given situation. A child under two who was dehydrated potentially could be referred to a doctor and given rehydration salts on the way in. This could be the outcome we want, or we may wish to rewrite our rules to be more precise—but always in the "when (something is true) then (do this)" format.

For more information on this real life example, read The Economist magazine's online article at: http://www.economist.com/research/articlesBySubject/PrinterFriendly.cfm?story_id=9440765.