架构动态业务规则 [英] Architecture for dynamic business rules

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

问题描述

我创建.NET中工资单应用程序。其中一项要求是,出席和演绎规则应该是动态的,灵活的,以最大程度。用户应该可以定义自己的规则,在这里的每一位员工将被绑定到一个考勤规则。

I am creating a payroll application in .NET. One of the requirements is that the attendance and deduction rules should be dynamic and flexible to the most extent. The user should be able to define his own rules, where every employee will be bound to an attendance rule.

解决方案之一是编译C#code。在那里的code到每一个考勤规则被存储在数据库中,并在运行时编译飞,但这不是因为规则的最优雅的解决方案仅读/由一个技术人员,的code也表现和可读性不会是最好的可能的事情的理解。

One solution is to compile C# code on the fly where the code to every attendance rule is stored in the database and compiled at run time, but this isn't the most elegant solution since the rules can only be read/understood by a technical person, also the performance and readability of the code will not be the best possible thing.

我想知道是否有一个解决方案\架构模式,可以让我定义和应用考勤规则和计算基于对他们的扣除,而无需编写脚本或动态编译C#code。

I am wondering if there is a solution \ architecture pattern that allows me to define and apply attendance rules and calculate the deductions based on them without writing scripts or dynamically compile C# code.

推荐答案

它是一个非常糟糕的做法,依靠code编译改变你的系统,你不妨说:规则是可以改变的任何时候,你需要的是开发者。

Its a really bad practice to rely on code compilation to change your system, you might as well say "rules can be changed any time, all you need is a developer".

如果你定义的规则,你可以存储在数据库中的参数,并与code,它在运行时读取它们应用它们。您的code将更加复杂,但这是我们付出的配置代价。

If you define your rules, you can store the parameters in the DB, and apply them with code that reads them at runtime. Your code will be more complex, but that's the price we pay for configuration.

您需要定义规则 - 即正式说什么paramaters我的使用,以及它们如何适用

You need to define the rules - ie formally say what paramaters my be used, and how they can be applied.

如。如果90%的出席率是指扣除5%,那么你会在数据库中存储这些2的值。您的code随后将获得实际的上座率,找到相应的行,并申请扣除。除非你的规则是如此复杂,他们不能在这样的参数为蓝本,采用了配置系统进行的最佳方式。然后,您可以提供一个简单的图形用户界面给用户,以调整在规则中的值。

eg. if 90% attendance means a 5% deduction, then you'll store these 2 values in the DB. Your code will then get the actual attendance, find the corresponding row and apply the deduction. Unless your rules are so complex that they cannot be modelled in parameters like this, using a configuration system is the best way to proceed. You can then supply a simple GUI to the users to tweak the values in the rules.

这篇关于架构动态业务规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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