MS验证块或工作流规则引擎? [英] MS Validation Block or Workflow Rules engine?

查看:70
本文介绍了MS验证块或工作流规则引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于将要开发的大型应用程序,我们正在选择Validation框架。尽管工作流程规则引擎并非严格意义上不是验证框架,但可以在不使用工作流程基础的情况下单独使用它。它似乎可以灵活地指定在运行时使用的数据库中的规则。但是,您似乎无法在代码中指定规则。



如果其中一项要求是更大的灵活性(不一定需要业务分析师来编辑规则) ,那么您会选择这两个中的哪个?为什么?

解决方案

这对您的确切要求非常重要。 灵活本身并不是一个好的要求,因为它无法衡量。



我对Microsoft Business Rules Engine并不熟悉,因此我无法对此发表评论。

但是,我对Microsoft企业库验证应用程序块(VAB)非常熟悉,在过去的一年中,它为我提供了很好的服务。它具有几个功能,可以灵活处理我正在处理的情况:




  • 它允许定义验证声明(使用属性)和使用外部配置文件(在生成实体时非常有用)。

  • 它包含一组可以使用的默认验证器,并且可以编写自定义验证器。

  • 它允许验证单个属性并允许您比较多个属性作为一个组(通过使用自我验证或自定义验证器)。

  • 它允许隔离地验证对象以及对象图。

  • 它允许您定义多个规则集,例如,允许您定义一组硬错误和一组警告。



VAB(或整个企业库)使您可以编写自定义配置源(IConfigurationSource),该源可用于在任何需要的位置定义业务规则。因此,从理论上讲,您可以将它们存储在数据库中,但是您必须自己编写这样的配置源,这将是很多工作。尤其是当您希望业务分析师能够定义验证并使用某种编辑工具更新数据库时,它认为使用VAB做到这一点将是非常令人毛骨悚然的。

>如果业务人员确实需要自己编写这些规则,则希望您有支持该要求的流程。例如,他们将如何测试他们的更改是否正确?您不希望您的业务分析师直接对生产数据库进行更改。



但是请考虑一下。如果要测试这些规则,我希望这些规则不会直接在您的生产数据库中更改,否则您将在事后进行测试。因此,分析师将在自己的环境中更改规则,您可能会在该环境中将新规则发布到测试环境,然后再发布到接受环境,最后发布到生产环境。如果要采取这些步骤,是否还应该使用数据库来存储那些业务规则?使用配置文件比使用数据库要容易得多。部署仅是文件复制,而不是将多个表的内容从一个数据库复制到另一个数据库。知道吧。


For a large application that will be developed, we are in the process of selecting a Validation framework. Although the Workflow Rules engine is not strictly a Validation framework, it can be used by itself without using the Workflow foundation. It appears to give flexibility of specifying the rules in a database that is used at runtime. However, it appears that you cannot specify rules in the code.

If greater flexibility is one of the requirements (not necessarily that the rules need to be edited by Business analysts), which of the two would you prefer and why?

解决方案

It quite matters in what your exact requirements are. 'Being flexible' is by itself not a good requirement, because it isn't measurable. It's very subjective if something is flexible.

I'm not familiar with Microsoft Business Rules Engine, so I can't comment on that. I am however very familiar with the Microsoft Enterprise Library Validation Application Block (VAB) and it has served me well over the last year. It has several features that make it flexible for the situations I’m dealing with:

  • It allows both defining validation declarative (using attributes) and using an external configuration file (which is very useful when your entities are generated).
  • It contains a set of default validators that can be used and custom validators can be written.
  • It allows validation of single properties and allows you compare multiple properties as a group (by using self validation or custom validators).
  • It allows validating objects in isolation, as well as object graphs.
  • It allows you to define multiple 'rule sets' which for instance allows you to define an set of hard errors and a set of warnings.

VAB (or the Enterprise Library as a whole) allows you write a custom configuration source (IConfigurationSource) which allows you to define your business rules wherever you want. So in theory you could store them in the database, however you will have to write such configuration source yourself, and this will be quite some work. Especially when you want your business analysts to be able to define validations and update the database with some sort of editing tool, it think this will be quite hellish to accomplish with VAB.

If there really is a requirement of the business people to write those rules themselves, hopefully you got process supporting this requirement. For instance, how are they going to test whether their changes are correct? You wouldn’t want your business analysts to make changes directly to the production database.

But please give this a thought. If the rules are going to be tested, I expect those rules not to be changed directly in your production database, otherwise you would be testing after the fact. So, the analysts would be changing the rules in their own environment and you’d probably be publishing the new rules from this environment to a test environment, and later on to acceptation environment and eventually to a production environment. And if you’re taking these steps, should you still use a database to store those business rules? Using a configuration file would make it much easier than using the database. Deployment would simply be a file copy instead of copying the content of multiple tables from database to database.

I'm interested in what others have to say about the validation frameworks they know well.

这篇关于MS验证块或工作流规则引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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