where Business Processes, Data and Rules meet.
Blog
Home / Business / Procedural or Declarative Logic, Differences and Benefits

Procedural or Declarative Logic, Differences and Benefits

0

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:

image

Procedural approach:

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:

Method2Procedure

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:

Procedure-NewLogic

 

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.

Declarative Approach:

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:

image

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:

Method2DecisionTable

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 http://blog.flexrule.com/?modeling-business-rule-and-decision

Conclusion:

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.

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.