🦸

Flow Best Practices

It takes a while to become a Flow Superhero, but we all have to start somewhere. Here are some tips and tricks that can help you in creating good flows that last.

General Flow Structure

Flow can easily become unreadable if you just keep adding nodes without planning ahead. To minimize the hassle to read and debug in the future, consider following.

Avoid Spaghetti 🍝

We’ve all done that - doing things the quick way now, just to make it work. The moment you decide to “just add a node, fix it later” is the moment you’re doomed to have unreadable spaghetti mess of nodes. Always try using the least amount of nodes possible

Group the Nodes 🎎

It’s a good idea to organize your flow nodes into groups. Groups can be designate certain high-level functional blocks that you may use, or different training scenario steps.

While a making a group, try to limit the amount of links to and from this group, ideally to 1 on each end.

To create a group, hold down Ctrl and then hold Left Mouse button, dragging the mouse as you define an area with your pointer.

You can set the name of a group, and customize its background color - to make it stand out.

image
ℹ️
You can also delete groups, but don’t worry, deleting a group does not delete the nodes inside of it. It only removes the frame around the nodes.

Use Tags and Comments 🎟️

Each node can have comments and tags on it. If you feel that it is not really apparent what is happening in your flow block, add them

Say you create a flow with a Switch block to go through user answers and count the correct ones, similar to this:

image

While it can be apparent to you what block does - while you cerate it - coming back to it in a couple of weeks time you might be scratching you head going “what on earth was that supposed to do?”

You can save the trouble by using comments to explain what the behaviour is all about, similar to this:

image

Adding comments to your flow will result in a neat understandable flow, that is easy to read, follow and understand. No worries what happens weeks and months from now, when you are to come back to this grand creation of yours! 😎

image

Flow Timing

It is super-helpful to have an idea of how the logic execution is passed along during the flow run. Here’s something to help you: a quick intro into a Split node and a Wait node.

Split Node

You might think that adding a split node will allow you to do several things simultaneously. But hey, that’s not how Flow works.

Flow is strictly sequential. This means that there is only one node active (executing) at any given time.

Take a look at the following split:

image

By the looks of it, there’s logging of 0, 1, 2, 3, and also disabling the [Player] object after logging 1.

The reality is that the flow will first log 0, then will continue all of the flow coming from the “0” output, until eventially getting to the end, or a non-instant node (for example, Wait node).

Only after that it will return back to the split and disable the [Player] object.

Confusing? It might be - especially when you are just getting started!

So when you can avoid using Split, do so. If you however have to use it, consider doing all the related work first, and continuing with the main flow from the last outgoing port of the Split node.

image

Wait Node

This node is great to give some delay for your actions, but it can also result in some unexpected behavior.

Let’s say you have a button, that should wait 10 seconds after being pressed and then do something. The direct way to implement it may look like this:

image

On the surface, this looks straightforward: you click the button, Flow waits for 10 seconds, and then prints out the message.

However, what happens if you click the button several times? The timer does not reset. Instead, a new wait is scheduled, and after 10 seconds of every press you will get a text.

image

So if you want to reset the timer, you should first enter Cancel and then In. This will stop the timer and restart it, without calling Finish.

This can be achieved by the Split node. Based on what we discussed above, see if you understand what’s going to happen here:

image
ℹ️
By the way, if you the waiting to abort, you can use the incoming port called Break.