Article
· Nov 27, 2023 4m read

What about DMN?

A few months ago, I faced a significant challenge: streamlining the handling of business logic in our application. My goal was to extract the business logic from the code and hand it over to analysts. Dealing with a multitude of rules could easily result in a code littered with countless "if" statements, especially if the coder lacked an understanding of cyclomatic complexity. Such code becomes a source of pain for those working with it—difficult to write, test, and develop.

 
Spoiler

 

After exploring various options, including attempting to teach analysts Python 😀, I stumbled upon the Decision Model Notation (DMN) for describing business logic. It proved successful — analysts could now articulate the business logic themselves, reducing over 1000 lines of code to just three lines + DMN description file.

Now, let's delve into the solution.

DMN, conceptualized in 2015 by the creators of BPMN, synergizes well with the latter but can also stand alone.

The core concept of DMN is the ability to manage decisions akin to other facets of your applications. For instance, consider a solution for calculating bonuses — you can modify it independently without impacting other application elements.

DMN operates in two ways:

  1. Analytical: Composing solution tables in programs, programmed by developers.
  2. Automation: Executing tables directly with the DMN engine, minimizing the risk of developers misinterpreting technical specifications.

And so, our code is similar to this 

 

 It will look like a simple table

Essentially, it's a table where the following are defined:

  1. Input data with their types (strings, booleans, integers, longs, doubles, dates).
  2. Rule rows applied to the input data.
  3. The rule selection policy (hit policy) determining the order and quantity of triggered rules (first successful, unique, all matches, etc.).
  4. The final decision corresponding to the matching rule row.

 

In conclusion, using Decision Model and Notation (DMN) offers several advantages in managing business logic:

  1. Clarity and Transparency: DMN provides a clear and transparent way to express complex business logic. It allows for the visual representation of decision tables, making it easier for both technical and non-technical stakeholders to understand and collaborate on business rules.
  2. Separation of Concerns: By extracting business logic from code and representing it in DMN, there is a clear separation of concerns between developers and business analysts. Analysts can articulate and modify rules without delving into the intricacies of code, fostering collaboration and agility.
  3. Maintainability and Flexibility: DMN enables easy maintenance and updates to business rules. Changes in business logic can be implemented by adjusting the DMN tables without the need for extensive code modifications. This enhances the flexibility of the system to adapt to evolving business requirements.
  4. Reduced Code Complexity: Utilizing DMN helps in reducing code complexity. Instead of embedding intricate decision-making logic within the codebase, the logic is encapsulated in a visual and structured format, making the codebase more manageable and comprehensible.
  5. Risk Mitigation: The use of DMN, especially in automated decision-making scenarios, mitigates the risk of misinterpretation or misimplementation of business rules. The DMN engine ensures that decisions are executed accurately based on the defined rules, minimizing errors.
  6. Efficiency in Development: Developers can focus on implementing the interaction between the application and the DMN engine rather than writing and debugging complex decision-making logic. This can lead to faster development cycles and reduced time-to-market for applications.

And yes, after all of this, you can use your DMN schemas with the data stored in your IRIS database - https://openexchange.intersystems.com/package/iris-dmn

If you are interested in learning more about DMN and the FEEL language and why the solution was made in JAVA, write to the questions, I will answer in the comments in more detail

 

Additional Information about DMN 

https://docs.drools.org/latest/drools-docs/drools/DMN/index.html  - the most detailed documentation

https://sandbox.kie.org/ - online sandbox where you can try to draw your own diagram 

https://learn-dmn-in-15-minutes.com/ - interactive tutorial

Discussion (1)1
Log in or sign up to continue