A key aspect of the high design cadence that Flowgear enables is the ability to re-use Workflows as Sub-Workflows. This capability closely parallels how functions call functions in code.
By designing your integrations so that each individual Workflow is only responsible for a specific section of a complex integration, you're enabling better composability.
For example, if you're implementing a sync of orders from an e-commerce platform to an ERP, you might consider factoring the solution into the following Workflows:
Create customer sub-Workflow - creates a customer in the ERP
Create order sub-Workflow - creates an order in the ERP
Update status sub-Workflow - changes the status of the order in the ERP
Order integration Workflow - parent workflow that calls create customer, then create order, then update status (moving the order status from New to Processed)
Using this factoring, not only are the first 3 Workflows candidates for re-use elsewhere but because the scope of each Workflow is well-defined, it's much easier to maintain the integration over time.
The Data Contract
Most sub-Workflows will need to have data passed in and/or out of them. This is done by adding a set of Input and Output Properties on the Variable Bar and in software this is known as a data contract.
The data contract ensures that anyone wanting to re-use a sub-Workflow doesn't need to be concerned about the inner workings of that Workflow, they just need to provide the correct Input Properties and evaluate the Output Properties that are returned once it completes execution.
Keeping your solution well-factored
In the example given earlier, it was easy to see which sub-tasks should be factored into sub-Workflows but these delineations are often not clear when you're just starting to build a new solution.
As your work progresses, you might realise that a large section of a Workflow you're busy with should actually be a sub-Workflow.
To make this kind of refactoring quicker, you can use the
Refactor to Sub-Workflow option available from the design canvas. To use it, select a range of Nodes on the design by either holding
CTRL and clicking the Node Header of the Nodes you want to include or holding
CTRL and dragging a selection rectangle around the Nodes you want to include.
Once you've made a selection, click
Refactor to sub-Workflow from the toolbar.
Flowgear will move the selected Nodes to a Sub-Workflow and create a reference to it as a sub-Workflow in the current Workflow. Additionally, Flowgear will automatically create the appropriate Input and Output Variable Bar Properties for any Data Flow Connectors that will pass data in or out of the sub-Workflow.