First you'll have to have a clear definition of what a "business rule" is. There are a bevy of candidates:
Information about your products.
Rules regarding sales that depend on time, location, customer, product, phase of the moon (aka closing date of the month), season, etc.
User roles (e.g., normal versus preferred customers, etc.)
Rules around accounts payable and receivable
GAAP rules
What exactly do you mean? It's a vague question that can be quite large if you let it.
You have lots of choices as to where they go in your code:
Data driven, stored in databases
Expressions in a Rete rules engine.
Middle tier classes if you're writing OO.
Properties or configuration files if you're doing declarative programming.
Executable rules expressed in something like JavaScript.
In your ERP, MRP, A/P and A/R systems.
Fronted by web services that your apps compose together.
Do you see the problem you're opening up? Your question implies that you have a well-defined problem and expect a simple, neat answer. The truth is that it's a broad topic.
This is quite a generic question and hard to answer -- but I'd say take a look at Behaviour Driven Development as a way of keeping business rules at the heart of your development.
Business Rules best practices state that the rules should be pluggable components. A minimalist approach would consist in coding them in a dedicated library, and proceed with Dependency Injection, or Reflection... Maybe you should investigate about Contracts Driven Development too, and look at www.businessrulesgroup.org/brmanifesto.htm to begin.
发布评论
评论(5)
首先,您必须对“业务规则”有一个明确的定义。有很多候选者:
到底是什么意思?这是一个模糊的问题,如果你允许的话,它可能会变得相当大。
对于它们在代码中的位置,您有很多选择:
你看到你所提出的问题了吗?您的问题意味着您有一个明确定义的问题,并期望得到一个简单、简洁的答案。事实上,这是一个广泛的话题。
First you'll have to have a clear definition of what a "business rule" is. There are a bevy of candidates:
What exactly do you mean? It's a vague question that can be quite large if you let it.
You have lots of choices as to where they go in your code:
Do you see the problem you're opening up? Your question implies that you have a well-defined problem and expect a simple, neat answer. The truth is that it's a broad topic.
这是一个非常普遍的问题,很难回答——但我建议看一下行为驱动开发< /a> 作为将业务规则置于开发核心的一种方式。
This is quite a generic question and hard to answer -- but I'd say take a look at Behaviour Driven Development as a way of keeping business rules at the heart of your development.
我建议您研究 MVC 范例 - 模型视图控制器。视图中不应该有业务逻辑,它应该全部在模型中。
I suggest you investigate the MVC paradigm - Model View Controller. There should be no business logic in the view, it should all be in the model.
答案取决于多种因素,例如
如果上述所有问题的答案都是“是”,那么您正在寻找一个规则引擎(drools、ilog 等)来实现您的规则。
如果您的答案是“否”,那么另一种方法是在代码中对规则进行建模,并牢记下面的
。从此处复制
The answer depends on multiple factors like
If answer is YES to all of them above then a rules engine (drools, ilog etc) is what you are looking for to implement your rules
If your answer is NO then the alternative is to to model the rules in code keeping below in mind
E.g. copied from here
业务规则最佳实践指出,规则应该是可插入组件。极简主义方法包括将它们编码在专用库中,然后进行依赖注入或反射...也许您也应该研究契约驱动开发,并查看 www.businessrulesgroup.org/brmanifesto.htm 开始。
Business Rules best practices state that the rules should be pluggable components. A minimalist approach would consist in coding them in a dedicated library, and proceed with Dependency Injection, or Reflection... Maybe you should investigate about Contracts Driven Development too, and look at www.businessrulesgroup.org/brmanifesto.htm to begin.