views:

3224

answers:

6

Hi, I'm supposed to create a simple rule engine in C#. Any leads on how I can proceed?. It's a minimalistic rule engine, and would use SQL server as the back end. Do we have any general blueprint or design patterns that generally apply to rule engines? What kind of .Net technologies can I use to design one? Any directions would be helpful. Thanks.

A: 

What kind of Rule engine you looking for? For styling practices? If so, go check out http://spoiledtechie.com/post/StyleCop-was-just-released!.aspx">StyleCop. Not the answer, but there might already be something out there for you.

Scott
@Scott, I'm looking to develop a business rules engine with C#. Like inRule or something, but a very simple one. And I'm looking for patterns or any blueprint, based on which i can create my rule engine.
+2  A: 
  1. I cannot believe you would implement your own considering there are so many available commercially and open source.

  2. I recommend taking a look at InRule as a great commercial option that is reasonable priced, or NxBRE in the open source space.

David Starr - Elegant Code
+6  A: 

If you're using .NET 3.0 or later, you can use the Rules Engine of Windows Workflow Foundation without having to acutally use Workflow.

I've done this on a project, and you can use SQL or XML as the backend, and it works great. You can use the IDE that comes with the Workflow examples and put it in your own apps. It's excellent.

Schnapple
A: 

Are you given any indication on method? (ie if this is supplemented by course material what are you currently learning?) If this is meant to be a fairly basic system you might find success looking into to Deterministic Finite State Machine and Nondeterministic Finite State Machine

jwarzech
@jwarzech, its not for any courses. It's a business rules engine, supposed to be commercial work - but its fairly simple. There are a couple of generic classes ( 10 or so? ) of rules. btw, I once did 'Theory of computation' in school. Thanks for the answer nyways.
A: 

You might find the accepted answer on this post helpful http://stackoverflow.com/questions/43805/example-of-c-based-rule-language#43882

jwarzech
A: 

If you have business analysts to program the high level rule engine, then fine - pick one of the before-mentioned rule engines or roll your own (including workflows). If not, then just code your business logic in code and if you ever need to hire business analysts and redo the system, you're in a good place to be.

JeeBee