Posted by: Carole-Ann | March 27, 2014

My first ‘Hello World’ rule

This blog has now moved. This post was originally posted on the Sparkling Logic blog.

Let’s go back to basics and explore how business rules work.  For that purpose, I am using the unavoidable ‘Hello World’ project.  I will show you today that agility can be obtained without a whole lot of complexity…  My first-grade son could do it, so it can’t be that hard ;-)

Before I start writing rules, let me take a very quick detour.  To make the exercise more concrete, it helps to have test cases so that we can see how the rules apply as we write them.

Prepare a test case

I personally find it easier to explain what decision logic does, or is supposed to do, when I have a concrete example to look at.

For our Hello World project, I want to select the proper greetings.  My decision logic will be based on names.  You could obviously make it a lot more sophisticated based on country of origin or the time of the year.  But for now, let’s keep it simple.

To test my logic, I will have a test case for World, but I will also create one for Joe, my favorite test subject.  I will actually create a few more for Jacques and Pedro.


Write the rule

A business rule is an IF-THEN statement.  It could also include an ELSE but it is typically recommended to avoid it.

Based on a set of conditions (IF part), the business rules engine will apply the appropriate set of actions (THEN part).  In our case, If the test case is for “World”, then we will choose the “Hello World” greeting.


If our system was going to say “Hello” all the time, we would need just one business rule…  But I would like to customize my greetings to say “Hi” to Joe, “Bonjour” to Jacques and “Vote” for Pedro.  Can you guess what the rules will look like?

Well, that was a trick question!  The rules are quite intuitive I think, but you might have a preference as to how they are displayed, or how you author them…

What is your preference?

I like data — I understand what it means


In that case, our patented RedPen approach might be the best choice.  As you click directly on the fields and their values, the rules are constructed and rendered as stickers showing the condition (in orange) or action (in blue).  You just have to click on the sticker to change it.

In this project, I have actually used RedPen to create these rules.  RedPen is always my default choice for constructing business rules, especially if I have data!


I like syntax — I understand what it does


If you know your rules, you may as well just type them in.  That is typically the preference of technically-savvy users.  They can type faster than they operate the mouse!  And Intellisense is always there to help too.

I like decision tables — I understand what must happen for each case


If you use spreadsheets a lot, you might opt for a decision table.  It is quite nice I must say when all the rules are very regular, meaning that they look at the same set of conditions with different values.  It helps validate visually that the rules have been captured exhaustively.

I like decision trees — I understand what must happen for each segment


If you think in terms of population segments, and treatment for that segment, a decision tree would allow you to conceptually visualize the assignments in a concise way.  They look nice and symmetrical when the rules are regular.  They are even more powerful when each path is looking at a different set of attributes!

I like decision graphs — I understand how we got to a conclusion


If you are more concerned about the different ways that lead to a conclusion, you might prefer decision graphs.  They are not very powerful here because there is only one way to reach each action, but think about an adverse action (decline for example), you might be required by law to audit the different ways you reach that conclusion.  Decision graphs are very powerful then!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: