Conditional flows

Everything is possible

In the previous page we looked at the basic flow and what it is.

Now, let's consider flows that can do more than just calculate 2+2 and email us the result:

Imagine we are a video games reseller, and we need to decide whether to sell a PG 18 game to a customer.

The following decision-making flow seems appropriate:

We begin by determining the person's age, this is our first state, State 1.

Then we look at that age, and need to see if the person is at least 18 years old. This is our second state.

Then, based on the outcome, we will either allow to purchase the game (state 3), or deny the purchase and require parental approval (state 4).

The most interesting part of this flow is the "Condition State". It applies a simple logic:

It states that the minimum age from first state ("Determine Age") should be 18.

In case this condition is correct (= The condition was successful), we proceed to state 3 ("Allow purchase").

In case the condition is NOT correct (= The condition was unsuccessful), we proceed to state 4 ("Deny purchase").

Example 1

We are Executing this flow for Jake, who is 16 years old.

The statement "Jake, who is 16 years old [state 1], is at least 18 years old [state 2]" is incorrect, and so we are denying the purchase [state 4].

Looking at the colors, you will notice that we have red states, green states and a grey state. Red states indicate a false result (negative outcome or unexpected error), while green states indicate success. Grey states are states that were never reached.

Determining Jake's age is successful, because we are simply fetching information here (for example - from a database).

Applying the condition state is not successful, because 16 is smaller than 18, not larger. So this state failed.

The condition state was programmed to go to state 4 when it fails, and so state 4 is executed. Since Jake's age means 'Deny purchase', the state completes successfully, and the flow execution is complete.

Example 2

We are Executing this flow for Anna, who is 20 years old.

The statement "Anna, who is 20 years old [state 1], is at least 18 years old [state 2]" is correct, and so we are allowing the purchase [state 3].

Anna is 20, and so the Condition State (State 2) is successful, thus proceeding to State 3 (Allowing the purchase). State 4 is never reached.

To summarise, our flow is like a blueprint for a business flow, and it had 2 executions. One execution resulted in the following path:

state1 -> state2 -> state4

And the second execution result in a different path:

state1 -> state2 -> state3