AvgJoe007
AvgJoe007

Reputation: 41

Application design - modifiable business rules

Am looking for some advice on the design of an application. As I'v signed an NDA I can't reveal too much about the actual business but will try to explain the requirement.

Essentially, we want to develop an application that will take a decision based on a customers credit profile. We will take data from a suitable provider (eg. Experian) and match it against the business rules. If the customer meets those rules, they get a green flag to be passed to the next process (and possibly another system, but am not worried about that for now); if not, they will get a red flag and not get passed on.

The client has indicated that they would like the business rules to be modifiable i.e. something that they can amend and thats not hard coded or stuck in the code somewhere. They have defined a set of rules as a 'template'. The system will only have one active template at a time, but over its lifetime might have many templates.

These rules would be composed of multiple operators checking different data types. Each phase/step of the rules would be allocated a certain weight. An example of a 'template' would be

So as you can see, there are comparisons/operators of various types (boolean, integer etc).

I am looking for a framework/advice on which I can build these 'templates'. This is a web job, so we know that we'll definitely be using a DB of some sort. The technology has not yet been decided, but would probably be between PHP & .NET. We think at this stage that a lot of this will be done in SQL (and would like to see if this is a good idea to pursue)

Are there any sample applications out there that I could go through? Has anyone done work of this nature before?

Thanks!

Upvotes: 3

Views: 300

Answers (3)

aroth
aroth

Reputation: 54806

If all your rules are that simple, you could use something like:

Rule {
    ruleId,
    templateId,
    comparisonType,
    fieldName,
    minValue,
    maxValue,
    scoreIfPassed
}

Template {
    templateId,
    rules
}

...so a Rule is associated with a Template, and specifies a comparison type to apply (like 'greaterThanMin', 'lessThanMax', 'exactValue', 'insideRange', etc.) to a given field. Then you can do:

user.score = 0;
rules = currentTemplate.rules;
for each rule in rules do
    if rule.comparisonType == 'exactValue' && user[field] == minValue
        user.score += rule.scoreIfPassed;
    else if rule.comparisonType == 'insideRange' && user[field] > minValue && user[field] < maxValue
        user.score += rule.scoreIfPassed;

    ...
end  

Upvotes: 0

Bj&#246;rn Pollex
Bj&#246;rn Pollex

Reputation: 76788

I don't think that letting your customers write their own rules in SQL and then executing those is a smart idea. Firstly, you could run into security issues (for instance, if they access parts of the database they shouldn't), and you reveal too much implementation specifics (what if they start using DBMS-specific operations, and you later decide to replace the DBMS).

Depending on the amount of work you want to put in here, this sounds like a good job for a Domain Specific Language. @Ozair suggested BPEL, but it might be overkill.

Upvotes: 1

Ozair Kafray
Ozair Kafray

Reputation: 13539

I think you are looking for Business Process Execution Language.

Upvotes: 1

Related Questions