规则引擎.NET [英] Rules engine for .NET

查看:346
本文介绍了规则引擎.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有业务需求,让电力用户编辑规则保险费率和入学率。我们需要一个Web用户界面,让他们说:这个产品只适用于人< 55,除非他们是来自德克萨斯州和自己的狮子狗或什么。编辑澄清:保险是疯了。该规则从产品到商品,州不同不断改变。

We have a business requirement to let power users edit rules for insurance rates and enrollments. We need a web ui that lets them say "this product is only for people <55 unless they are from Texas and own a poodle" or whatever. Edit for clarification: Insurance is insane. The rules differ from product to product, state to state and change constantly.

我们看了几个规则引擎,但商业的是100K +和开源的人不要T似乎嗯,完了。 Windows工作流工作,如果我们提前创建规则,但它们建造在运行时似乎都需要绕过代码访问安全性。这是可怕的。

We looked at a couple of rules engines but the commercial ones are 100K+ and the open source ones don't seem um, finished. Windows Workflow works if we create the rules ahead of time, but building them at runtime seems to require bypassing code access security. That's scary.

我们是坚果彻底改造这个轮子?是否有.NET一个更好的选择?

Are we nuts to reinvent this wheel? Is there a better alternative for .net?

推荐答案

我不认为规则的评估将是挑战。我认为更大的挑战是如何的解析<​​/ em>的用户可以进入规则。对于解析规则,你应该考虑创建一些DSL。 Martin Fowler的这里有对此的一些想法。那么也许 ANTLR 则可能是值得一试。

I do not think that the evaluation of the rules will be the challenge. I think that the greater challenge is to parse the rules that the user can enter. For parsing the rules you should consider to create some DSL. Martin Fowler has some thoughts about this here. Then maybe ANTLR then might be worth a look.

有关评估部分:我在金融行业工作,也有复杂的规则,但我从来没有使用规则引擎。命令式编程语言(在我的情况C#)的手段是(直到现在)就足够了。对于一些场合,我正在考虑一个规则引擎,而是一个规则引擎的技术风险(*)总是比预期的收益越高。该规则是(直到现在)从来没有那么复杂,这需要声明性编程模型。

For the evaluation part: I work in the finance industry and there are also complicated rules, but I never had to use a rule engine. The means of an imperative programming language (in my case C#) were (until now) sufficient. For some occasions I was considering a rules engine, but the technological risks(*) of a rule engine were always higher than the expected benefits. The rules were (until now) never that complicated, that declarative programming model was needed.

如果您使用的是面向对象的语言,您可以尝试应用的规范格式。埃里克·埃文斯和马丁·福勒已经写了一个更详细的解释,你可以在这里找到 。 。或者你可以写自己的简单规则引擎

If you are using a object oriented language you can try to apply the Specification Pattern. Eric Evans and Martin Fowler have written a more detailed explanation, which you can find here. Alternatively you can write your own simple rule engine.

(*)脚注:不知怎的,你将需要嵌入规则引擎到你的应用程序,它极有可能写在某个对象面向语言。因此,有一定的技术界限,你必须弥合。每个这样的桥是技术风险。我曾亲眼目睹用C写的。刚开始的C程序有时产生的核心转储和拆毁整个Web应用程序的规则引擎Java Web应用程序。

(*) Footnote: Somehow you will need to embed the rule engine into your application which is very likely written in some object oriented language. So there are some technological boundaries, which you have to bridge. Every such bridge is a technological risk. I had once witnessed a Java web application using a rule engine written in C. At the beginning the C program sometimes produced core dumps and tore down the whole web application.

这篇关于规则引擎.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆