where Business Processes, Data and Rules meet.
Blog
Home / Business Rule / Advanced Domain Specific Language for Business

Advanced Domain Specific Language for Business

0

In this post we are going to show you how to extend DSL Natural Language to suit your needs and to use your business language as the basis for rule modeling. Then we are going to implement and refactor the logic for calculating the salary of an employee based on the following components:

  • Bonus
  • Commission

Let’s say we have the following logic for the salary calculation in Natural Language form:

DSL-Pay0

If you are not familiar with Natural Language you can find it here. Here, this logic calculates the total amount based on employee Salary.

Now the issue with this logic is that it does not really describe the method of calculation and how it is achieved! Despite a couple of comments and a name for the logic of “Salary calculator”, we are expected to guess.

Business Friendly Statements

One of the main benefits of this domain specific language using Natural Language in modeling logic is that you can wrap complex or unclear statements into business friendly, meaningful expressions.
So for the above logic we can add a different section describing when to call this to make it more meaningful. What we need to do for this calculation is to:

  • Add base salary
  • Add bonus
  • Add commission

So let’s define that logic in Natural Language (NL) here:
DSL-Pay1

At this stage, your comments are all gone. You don’t need them because the logic is self-descriptive. And more importantly, it can be reused.

Parameterized Logic

Let’s assume those 10% and 30% bonus and commissions are variables, so we need to change them based on different scenarios. So in that case our new logic should accept a parameter. In the logic of Salary calculation, therefore, we should pass values for those parameters, as follows:

DSL-Pay2

Now it is apparent that this logic can handle different variables of commissions and bonus.

Benefits

There are many benefits to using this approach:

  • No comments are required – business rules are self-descriptive
  • You’ve made a reusable, parameterised business rule
  • You can test and debug each aspect of this logic independently
  • And more importantly – you modelled an executable business rule that everyone understands in their own spoken language

Conclusion

Using this method, you can model business rules that not only document your business, but also are executable. You can run, test and deploy these to your production environment. DSL allows you to build executable business rules that are modeled based on your business language. Now your business logic (i.e., rules, decisions, etc.) implementation is not separate from its documentation and specifications.

Read More

  1. Advanced Domain Specific Language for Business
  2. Business Glossary
  3. Business Rule Language
  4. Agile methodology and BDD vs Business Agility
Recommended Posts

Leave a Comment

You must be logged in to post a comment
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.