Rules engine.pptx

27 views 16 slides Jun 15, 2023
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

Presentation introducing the Rules Engine topic


Slide Content

RULES ENGINE Spryker user group, June 14, 2022

About me 20+ years in the industry 4.5 years at Spryker Technical Director at Turbine Turbine Kreuzberg Twitter LinkedIn

Do you know where your business rules are? in the code all over the system no overview, no central point you need developer to find/change/add hard to maintain, check, verify, debug

Rules engine to the rescue easily maintained and edited can be written in a natural-language can be updated quickly by users rules themselves are "separated" from the application

Short history of Rules Engines Around since the early 1990s when vendor started offering enterprise solutions Early adopters of those commercial systems were rules-heavy industries such as finance and insurance

Don't we have a state machine? Purpose: Rules Engine is designed to evaluate and execute a set of predefined rules or conditions. It operates on a set of inputs and produces outputs based on the conditions specified in the rules. State Machine is a mathematical model that represents the behaviour of a system. It defines a set of states and transitions between these states based on certain events or inputs. Execution Model: Rules Engine evaluates a set of rules in a sequential manner, usually in the form of "if-then" statements. It matches the input data against the conditions specified in the rules and executes the actions associated with matched rule. State Machine executes based on the current state and the input events. It transitions from one state to another based on the defined transitions and the occurrence of specific events. Complexity: Rules Engine is suitable for handling complex business logic with numerous conditions and actions. State Machine is typically used to model and control the behaviour of systems with well-defined and relatively simple states and transitions.

When to use a rules engine? When you have a large number of rules or conditions that need to be evaluated. When the rules or conditions are subject to frequent changes or updates. When you want a more declarative and flexible approach to defining and managing business logic.

When to use a state machine? When you need to model and control the behaviour of a system with distinct states and well-defined transitions. When you want to represent a system that reacts to events and needs to maintain a particular state. When you have a system with a finite number of states and relatively simple behaviour.

What is a rule? A rule is a statement or a set of statements that define a condition that must be met for a particular action to be taken. Rules are often expressed in a structured language that is designed to be easily read and understood by both humans and machines.

What is a rule? Rule consists of two parts - condition and action .​ We group rules in sets .​

How does a Rules Engine Work?​ Rules Engine evaluates the rules in a ruleset against the provided data. If the rules are met then Rules Engine will trigger one or more actions. We have multiple execution strategies depending on the needs of the system.

Rules Engine execution strategies First Match Strategy : In this strategy, the Rules Engine evaluates rules one by one in a specified order until it finds the first rule that matches the given data. Once a matching rule is found, the associated actions are executed, and the evaluation stops. All Match Strategy : In this strategy, the Rules Engine evaluates all rules in the rule set against the data, regardless of whether a match is found. Priority-based Strategy : In this strategy, each rule is assigned a priority or order value, indicating its precedence over other rules. The Rules Engine evaluates rules in the order of their priority, starting from the highest priority rule. Once a matching rule is found, the associated actions are executed, and the evaluation stops. Conflict Resolution Strategy : In situations where multiple rules match the data, a conflict resolution strategy determines how conflicts are resolved. It specifies rules for prioritising conflicting rules, such as considering the rule with the highest priority, applying rules based on specific conditions, or using rule dependencies. Chaining Strategy : Chaining strategies allow rules to be linked together, where the output or action of one rule becomes the input for another rule.

Benefits of a Rules Engine Increased Flexibility : A Rules Engine allows you to easily modify the rules without having to modify the underlying code. This can be useful in situations where the business logic is constantly changing, such as in a fast-paced startup environment. Improved Consistency : A Rules Engine can help ensure that decisions are made consistently and fairly across all data sets. This can be especially useful in situations where there is a high volume of data to process. Improved Scalability : A Rules Engine can help you scale your business by automating decisions that would otherwise require manual intervention.

Downsides of Rules Engine Complexity : As the number of rules grows, the complexity of managing and maintaining them can increase significantly. Rules Engines can become difficult to comprehend and modify, particularly when dealing with complex rule dependencies (chaining). Limited expressiveness : Rules Engines are well-suited for decision-making based on straightforward conditions and actions. However, they may struggle with handling complex or dynamic logic that goes beyond simple rule evaluations. ​ Performance : Evaluating a large number of rules against extensive datasets can impose a performance overhead. The execution of complex rules may require significant computational resources and processing time, impacting system responsiveness.

Demo

QA Twitter LinkedIn