1,Variable business
Have you tried the following situations during system development? If you have tried it, consider using the rule engine.
Serial number |
Problem |
Example |
1 |
Business Rules come from one or more tables |
Store Member points table, parking lot billing standard, express delivery fee calculation table, customer credit rating table |
2 |
Business Rules are written by the customer and are difficult to be structured. |
Wage calculation, formula calculation, insurance calculation, and formula system. |
The business rule is from a table. Generally, the table has multiple columns, and these columns have a condition and result relationship. For example:
Points |
Member grade |
Discount |
0-100 |
Ordinary Member |
-- |
100-1000 |
Silver Member |
0.99 |
1000-5000 |
Gold member |
0.9 |
5000 ~ |
VIP |
0.85 |
In these three columns, points and membership levels are the conditions, while discounts are often the results. Results are usually obtained by conditions. The above tables can be saved in data tables, but this practice is really not recommended, the table above may be implemented by users, but may change in a month or two.
These table-based rules can be understood as structured rules.
However, users often have unstructured rules that require software companies to implement. As shown in the table above, the customer adds the following requirements: A. blacklisted Members do not have discounts; B. Women's Day, January 1, March 8, female members are discounted by 98, C, and product X.
It is not a table-based rule. It can be understood as a non-structured rule.
In fact, unstructured rules are just the formulas that users can easily write. Maybe many member systems have already handled these problems, but for small development teams or teams with insufficient experience in the industry, the above requirement is "abnormal" because it cannot be implemented by yourself.
2, Rule Engine
The rule engine is designed to handle complex and changing businesses. It encapsulates these changes into the rule engine and provides common interfaces, it allows implementers or customers to easily change the rules without changing the lower-layer code.
The CKRule rule engine is not implemented by using the rete algorithm, but by compiling, that is, the rules are implemented by code and written in. Net4.0 C # language.
The Rules Engine handles the above issues very well. For Table-based data, you can define a decision table for processing. For unstructured rules, you can directly write formulas for processing. For Table format data, you must first mark the condition column and the conclusion column. The engine scans each row of data and uses the condition column to determine whether the condition is correct. If the condition column is true, the data in the conclusion column is executed.
For unstructured rules, developers can define very simplified keywords in the engine to compare logical and Conclusion operations. These definitions are also called in the business system to develop an interface suitable for the current business system and provide friendly and simple formula editing. In CKRule, an unstructured rule is called a customer rule pool. Its architecture is as follows:
From this, we can clearly see that end users always operate on unstructured formula editing on the business system, and the formulas written in the test are saved in the database, end users do not need to be directly connected to the engine. This feature is a powerful customer rule pool function.
You can edit the basic metadata in the engine and then edit the formula in your business system even if you have business rules that have no headers. These formulas are compiled using C # And you can easily change any business rules. If the keywords, comparison logic and Conclusion logic defined by the developer are perfect enough or the customer formula is simple enough, it is absolutely feasible and cost-effective to hand over the customer rules to the customer.
For more information about the CKRule architecture, case studies, and download applications, see:
Http://www.ckrule.com/