Business Rules

Practice Writting Business Rules (AND in BPMN) !!!!

  • Describe how a company does business
  • Describe what a company must enforce
  • In the form of constraints or conditions
  • Written in normal language
  • Owned by the business partners
  • Implemented by IT
  • Have to be nurtured, protected and managed.
  • Make the company more competitive to other companies
  • Business rules are decision points in BPMN (activity before a gateway)

Advantage * 4

Consistency: Rules help business make fair & consistent decisions, because human tend to do make varied decisions, business rules keep human factors out of the scope and thus Improve Decision Making

Speed: Using business rules facilitates automatic technical processes that are free of human touch, and that, in turn, removes human involvement which adds time to the process, therefore the process is more efficient and less costly (Cost Reduction).

Types of Business Rules

Definitional:

Defines how the business is run.

Help make business decisions.

Provide answers to questions arising in day-to-day business activity.

Ensure consistency of operational business decisions

Has pattern

It is like the law of business operation, cannot be broken.

Behavioral:

Obligational = business law/policy = can be broken, BUT will receive a response 

Prevent undesirable situations (states) the business deems

Governs all on-going business activities

No pattern

Sources

People: experts and managers who have the expertise in making decisions, when people go, business rules are gone to, so it is better if we get the rules from these people’s head, and reduce the risk to lose expertise

Documentation: law documents and policy documents where rules are defined, long and complicated

Code: dig through code to find out how rules are implemented, can take a long time, better if people keep rules in one place

Business Rule Management System

Provide a unified place to manage business rules.

  • If you have 10 subsystems and rules are implemented in each of them individually, it will take forever when changes are needed.
  • BRMS is external to our application, which is a good thing.
  • If you have a central BRMS, businesspeople can come in and add/remove rules to a repo, IT leverage them and pick from the rules when we deploy them into our system
Business Rules 是一种用于定义业务规则的工具,它允许你在不编写代码的情况下定义条件和操作。 下面是一个示例,展示如何使用 Business Rules 来定义条件和操作: ``` from business_rules import rule from business_rules.actions import BaseActions, rule_action from business_rules.fields import FIELD_NUMERIC from business_rules.variables import BaseVariables, numeric_rule_variable class ShippingVariables(BaseVariables): def __init__(self, order_total): self.order_total = order_total @numeric_rule_variable def order_total(self): return self.order_total class ShippingActions(BaseActions): @rule_action(params={'discount_amount': FIELD_NUMERIC}) def apply_discount(self, discount_amount): self.discount_amount = discount_amount @rule(name='Free shipping for expensive orders', description='Free shipping for orders over $1000', variables=ShippingVariables) def free_shipping_for_expensive_orders(facts): return facts.order_total > 1000 @rule(name='Apply discount for large orders', description='Apply a 10% discount for orders over $500', variables=ShippingVariables, actions=ShippingActions) def apply_discount_for_large_orders(facts): if facts.order_total > 500: ShippingActions.apply_discount(discount_amount=facts.order_total * 0.1) return True return False ``` 在上面的示例中,我们定义了两个规则:一个用于决定订单是否可以享受免费运输,另一个用于在订单超过 $500 时应用 10% 的折扣。我们还定义了一个 ShippingVariables 类,它包含了我们需要在规则中使用的变量(在这种情况下,只有订单总额),以及一个 ShippingActions 类,它包含了我们可以在规则中使用的操作(在这种情况下,只有应用折扣)。 规则的定义非常类似于 Python 函数。每个规则都有一个名称、描述、变量和操作(可选)。每个规则还有一个返回 True 或 False 的函数,用于判断条件是否满足。如果规则包含操作,则可以在规则中使用它们来改变规则外部的状态。 在这个例子中,我们使用了一些 Business Rules 提供的辅助函数,如 numeric_rule_variable 和 rule_action,以方便地定义变量和操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值