There are many ways to externalize your application logic, by means of which you can make your application more flexible. By making your application flexible, you allow the logic of your application to adapt to changes – with no code change – based on different circumstances outside of your application.
Let’s say in your application you have a logic that, based on the Scope of a Record, associates a Status to the Record. This would look like something similar to the following code:
One of the ways of externalizing logic is to use a procedural engine. In a procedural engine, you probably have a one-to-one mapping to each line of your code:
As you see in this approach, using procedural logic you implement your code line-by-line in the rule engine.
And the coded implementation of your actual logic will appear as follows:
The procedural approach is fine when the people maintaining and deploying the logic have programming skills, or the logic itself is procedural in its nature.
However, there is other approach to solving this problem. This occurs when you model the logic using a decision modeling approach. One of the many ways of implementing this type of model is to use a Decision Table. With this approach, you can model the logic using any spreadsheet (as the Domain Specific Language). In this example we used MS Excel to model the decision. However, you can also use XML language, similar to the procedural approach.
Your logic looks something like this:
As you can see, your rule implementation is not using any procedural approach. Therefore the benefit is that it is more understandable and maintainable even to those with no programming skills.
And your application code looks like this:
The only difference is the piece that calculates and assigns the Status.
When you use the procedural approach, you need to know how to model the logic and how to create a set of instructions to implement it. But in a declarative approach you only need to know how to model the logic.
Modeling Business Rules and Logic:
There are many ways of modeling business rules and logic. To learn more, please visit https://www.flexrule.com/archives/modeling-business-decision/
The first and most obvious benefit of externalizing your application logic using a rule engine is that you can update this logic simply, with no headaches and by avoiding the ceremony of deployment processes. Updating your application logic becomes more like updating the contents of a site (i.e., config file, resources, etc.) – which is always easier and safer than updating assemblies, isn’t it? Therefore, your deployment process is significantly simplified.
The procedural approach always has its own place, especially if you do not have time to extract the actual logic from your application and you want an easy and quick win in your application logic in order to make your application flexible. However, using a declarative approach has all the benefits of the procedural approach, plus it has more benefits. It allows your application logic to become more understandable and maintainable outside of your development team. Therefore, embracing changes would have faster turnaround with less or involvement of developers. It becomes cheaper, quicker and easier to adopt changes.
Last updated January 24th, 2020 at 04:03 pm, Published August 5th, 2014 at 04:03 pm