Workflow Design Anti-Patterns
Author:
Fluent Commerce
Changed on:
16 Nov 2023
Overview
Anti-Patterns are patterns found which are not recommended practice, or violate best practice guidelines, and can be harmful to performance and reliability.
Key points
- Avoid cyclic processes in workflows to prevent performance issues and undesired behavior, ensuring entities return to previous states with user-driven logic.
- Minimize trigger states in Rulesets for simplified and consistent workflow management.
- Exercise caution with immediately scheduled events, especially when not essential, to maintain optimal workflow performance and prevent asynchronous processing.
- Utilize the rule for changing entity states, ensuring accurate tracking, simplified configuration, and a correct Workflow graph.
`SetState`
Cyclic Processes
A Cyclic Process occurs when one Ruleset calls another Ruleset, which then calls the first Ruleset back.
- Cyclic Processes should be avoided in your Workflow as they can lead to poor performance and undesirable behavior, including when events are scheduled.
- Entities can still be put into a prior state as long as there is a User Action driving the logic.
Too Many Trigger States
A Ruleset has too many trigger states when it is triggered by more states than the Ruleset's operation is applicable to.
- Having too many trigger states for a Ruleset should be avoided as Workflows with fewer triggers are simpler to manage and more consistent in behavior.
Incorrect usage of Immediately Scheduled Events
An Immediately Scheduled Event is one scheduled to happen within milliseconds of 'now'.
- Immediately scheduled events should only be used for cross-domain and cross-retailer events.
- Using too many of these events is not recommended in most cases as it is less performant.
- Immediately scheduled events create new execution contexts that will be processed asynchronously and separately from the current Workflow branch.
Changing State within a Custom Mutation
Changing state within a custom mutation occurs when you use any rule, other than the provided
`SetState`
- Using the rule enables the Workflow Engine to correctly track state changes. Using a custom mutation may lead to NO_MATCH events and other problems.
`SetState`
- Using the rule to manage state changes will make the Workflow easier to configure and troubleshoot later and avoid duplicating the
`SetState`
rule's logic.`SetState`
- Using the rule ensures the Workflow graph will be correctly drawn in the Workflow Builder
`SetState`