For specific examples, see drools5.1 rule stream example.
I have been developing applications based on rules and rules engines for a while. Now I will write some experiences for your reference.
1.The separation of logical expression and execution. This is fundamental.The implementation of business logic can be subdivided into the expression and execution of business logic. In traditional code, expressions and executions are mixed and expressed and executed by code. In rules-based and Rule Engine-based systems, rules are used for logical expressions, engine. Logical expression and execution are separated.
2.In a rule-based system, the correctness of the system depends on the correctness of the rule.A rule is like a series of small pieces that express "know-how". By reasonably combining the rule piece (The role of the Rule stream), it expresses the complete computing logic. Rules, rule flow, and rule engine are core concepts.
3.
Dynamic and configurable computing logic with inherent scalability.Because the computing logic is expressed and implemented by rules, and the rules are dynamically configurable, the computing logic is dynamically configurable. This is very promising and advantageous for modern commercial applications that are complex and changeable and require rapid deployment. Traditional code is usually a static logic. It achieves certain scalability through the design pattern technology and has great requirements on design thinking.
4.
Rules are more readable than code.If the rule generation and management systems are more user-friendly, users can create application logic by writing rules and rule streams.
5.The rules are self-explanatory.You can track the execution of the rule and clearly see the process of generating the final calculation result. In traditional code, although some statements can be printed, the program structure is limited to debugging by programmers.
6.The reusability of computing components.As described above, rules are used for expression and engines are used for execution. The variability of business logic is usually reflected in expression rather than execution. Therefore, the expression is changeable, while the execution is relatively stable. The rule engine is a reusable part of computing components.
7.
Policy and Mechanism separation.From the perspective of software design, this also reflects the separation of policies and mechanisms. Rule expression is a policy, and the engine is a mechanism. The policy is variable and the mechanism is stable.
All in all, rules-based and Rule Engine-based systems are indeed a new computing solution with great potential.