How to Write Business Rules

on September 27, 2023
How to Write Business Rules

Tips for Business Analysts on How to Write Business Rules

Throughout the years, the business rules experts at Sparkling Logic have provided tips on how to write business rules. This post consolidates some of the best of the best with example business rules. Note, the exact syntax you use for writing business rules will depend on the rules engine that you use. While there is no universal business rules language, there are common features (and pitfalls) that we will address. For those of you new to business rules, we recommend you start by reading our business rules FAQs.

Differentiate between Decisions and Process

Whether you’re an insurer, consumer lender, or healthcare provider, you’re probably using business rules to manage applicant eligibility. Requirements may include certain age, state of residency, and income requirements. Are you calculating age based on an applicant’s birthdate? Should you store state information as an abbreviation (CA instead of California)? How do you handle rounding with income? These data-processing steps are best addressed with procedural code instead of business rules. Save your business rules for what’s truly decisioning logic such as determining applicant eligibility.

IN is better than OR

Now let’s say a particular product is only available in CA and TX. You could write something like “IF the applicant is from California OR the applicant is from Texas…” However, using OR can get confusing very quickly, especially when you mix OR with AND. Let’s say for both states, the minimum age requirement is 21. You write: “IF the applicant is from California OR the applicant is from Texas AND the applicant is at least 21 years old…” Does 21 apply to Texas or both California and Texas? You would need to add parentheses to make the statement more clear. “IF (the applicant is from California OR the applicant is from Texas) AND the applicant is at least 21 years old…” The more you mix OR with AND, the more parentheses you will need to add to keep the order of operations correct.

Rather than using OR, use IN instead. IN allows you to create lists, which make it easier to keep track of each criterion. With IN, you could write something like “IF the state of the applicant is IN (California, Texas) AND the applicant is at least 21 years old…” IN makes it much clearer than an applicant has to meet both state and age requirements.

Avoid ELSE

ELSE is one of those atomic words which works fine when you only have one criterion. If age was your only requirement, you could write “IF the applicant is at least 21, THEN applicant is Eligible. ELSE reject the application.” However, your business most likely has multiple eligibility criteria. In order to use ELSE, you would have to make sure you spell out every situation that would not be negated by ELSE.

Instead, think in terms of the default and exceptions. The default is what happens most of the time and the exceptions are the exceptions to the default. With that mindset, focus your rule writing on exceptions. Going back to our earlier example, the default would be that most applicants would be ineligible because the product is only available in 2 states. You could write something like “IF the state of the applicant is IN (California, Texas) AND the applicant is at least 21 years old, THEN the applicant is eligible.”

Execute Business Rules in a 2-Step Process

So how do you address business rules for the default? That depends on your rules engine. For example, SMARTS™ Business Rules and Decision Management Platform allows users to set a default action when none of the rules fire. If you don’t have that capability, then you can establish a 2-step process. In order to do so, you must write your default rules in reference to the action or outcome of the exception rules. Then, you can schedule the exception rules to fire first and then default rules to fire second.

For example, let’s say the action to take once an applicant is deemed eligible is to change their application status from “Applied” to “Eligible,” you could write your exception rules as ““IF the state of the applicant is IN (California, Texas) AND the applicant is at least 21 years old, THEN change the applicant status to Eligible.” You could then write a default rule “IF the applicant status has not changed (is still Applied), THEN change the applicant status to “Ineligible.”

Order instead of Prioritize

Priorities allow rules to jump ahead of all other rules and execute first. Outside of the Rete algorithm, you don’t really need to use priorities. That’s because rules typically execute in the order that they appear. Therefore, instead of using priorities, simply order your rules in the manner you want them to execute.

In complex cases, you can avoid priorities by decomposing your decision into steps. For example, let’s say applicants could be eligible for multiple products but you only want them to see one. You can create a rule set that determines eligibility for all products. This would execute as the first step. Then, you can create another set of rules that ranks the products and selects the best for an applicant. Best can be defined according to your goals such as maximizing profitability. This would execute as the second step.

How to Write Business Rules? Go For Simplicity

In summary, when in doubt, follow the KISS principle, “Keep it simple, stupid” (or the grade school English class version “Keep it Short and Sweet”). In addition, leverage technology that will make your job easier, not create more obstacles. For example, learn how Sparkling Logic is using generative AI to simplify business rule writing and other use cases for generative AI to simplify decision management for business analysts. Or learn how you can leverage business terms to further simplify rules authoring and maintenance. While simplicity will require more time in thinking through the design of your business rules, your future self along with your colleagues will thank you for it.

Search Posts by Category


Sparkling Logic Inc. is a Silicon Valley-based company dedicated to helping organizations automate and optimize key decisions in daily business operations and customer interactions in a low-code, no-code environment. Our core product, SMARTS™ Data-Powered Decision Manager, is an all-in-one decision management platform designed for business analysts to quickly automate and continuously optimize complex operational decisions. Learn more by requesting a live demo or free trial today.