Team:
I am building a business rules engine that is contextually aware — but it’s weighted — or in other words each business rule has a level of granularity defined by the segments of a key. The segments are not combinatorial in that they cannot be weighted in any order, but rather permutable like a combination lock (interestingly enough improperly named but widely accepted).
However, to reduce the amount of code that’s necessary to provide the business rules we are only building exclusion files meaning that each segment could end up with a specific key value or ALL.
So, now that we have an abstract background, let’s take a concrete example. The defined segments are as follows:
- Line of Business (LOB)
- Company
- State
Now, let’s assume for this example that the LOB is ABC, Company is G and State is WY. If you break that down I should get the following permutations:
- ABC_G_WY
- ABC_G_ALL
- ABC_ALL_WY
- ABC_ALL_ALL
- ALL_G_WY
- ALL_G_ALL
- ALL_ALL_WY
- ALL_ALL_ALL
However, I need an algorithm to solve that problem. The segments must also be returned in the aforementioned order because you must always find the most finite rule first.
I look forward to your responses and thank you all in advance!
1 Answer