views:

858

answers:

7

Greetings!

Working on a web based project were business rules and logic need to be customized by client. I want to do this without having to recompile the application every time we sign up a new client on the system. The architectures I have outlined so far are:

  1. Windows Workflow: Creating dynamic workflows and saving them to the database.
  2. Reflection: Creating a business rules interface and use reflection to load the custom client assembly.
  3. A true business rules engine
  4. Implementing an IOC Container like structure map. [zaff: added 6/4]

Have you ever implemented anything similar to this? If so, what is your experience? And finally is there another solution that I should be exploring?

Thanks for your help!!

A: 

You don't consider the rules engine in Workflow Foundation to be a true business rules engine?

John Saunders
This isn't an answer to the question, it would be better as a comment.
Sam Meldrum
@Sam: are you the OP? If it's not your question, can you determine it's not the answer? Also, in what way is it not the answer, if he finds there's no reason not to use it?
John Saunders
+1  A: 

You can do data driven business rules, like this. Decision trees can be a good way to go as well.

You might also think about aspect-oriented programming as a way to implement business rules.

My only caution with a Rete induction rules engine is that the rule sets should be kept small and close to the objects that use them. If you can encapsulate the behavior of an object in a rules engine that's part of its state, all the better. I don't care for the "enterprise" solution that dumps thousands of rules into a singleton rules engine that becomes a dependency for every part of the enterprise.

duffymo
+1  A: 

This may not be the best approach, but my company has implemented your #2 option in several cases, with success.

We basically configure clients in a database or config file, and for each client, there would be a lookup table that stores a class name to invoke for whatever business operation to perform. When the code gets a request for client A, it looks up the class to use, and creates it and executes it via reflection.

I'm not a huge fan of putting code-related things in the database, but it actually works ok and is not too complicated in this case.

Andy White
A: 

I like WF, but if you've looked at it and decided you want something different, you should look at K2. Also, BizTalk has BRE support.

JP Alioto
A: 

I created a dynamic rule engine based on the following open source .NET Business Rule Engine NxBRE. I used the Flow engine as the primary example for my dynamic rule engine.

I used the same architecture mentioned in your question.

Michael Kniskern
+1  A: 

I have implemented most of the approaches you mention. The answer may depend on a variety of factors.

What client role(s) will be making the changes to the business rules (e.g. business analyst, developer, power user, etc.)? Meaningful support for business analysts may require a rules engine with externalized rules in a db and a useable UI. Meaningful support for developers might be as simple as leveraging something like MEF (http://www.codeplex.com/MEF).

You might also factor in how often will the business rules need to be changed and what sorts of associated operational requirements may apply (e.g. host process must remain running, app domain unloading ok, etc.). A good selection may require some careful thought about likely vs. unlikely future needs.

Jason Weber
+1  A: 

I suggest a combination of 1 and 3.

But don’t store the workflow in a database, store it is a decision tree or rule flow (as we call them).

Changing the workflow to accommodate a particular, customer, or federate them to their profile is a simple task when you have a visual, action-driven tool, such as Visual Rules. There is also a lot of benefit to having your business analyst or support person make that change, without having to adjust the code.

Also none of these requirements call for a complicated AI tools such as RETE and inferencing- Sequential Logic is best.