Skip to main content
All CollectionsHow-tosCertification Examples
Example Approach: Refactoring Stories
Example Approach: Refactoring Stories

Walk through common refactoring steps in Tines stories using simple scenarios.

Yanni Hajioannou avatar
Written by Yanni Hajioannou
Updated over a month ago

Overview

One of the best practices to follow when building stories in Tines is refactoring. In this article, we cover some simple scenarios that showcase the most common methods of optimizing your story builds.

Tines references

Before getting started, we recommend familiarizing yourself with the surrounding functionality this article covers:

Make it happen

Collapsing multiple event transform actions

In this video, we look at an example with four event transform actions. The first three event transforms are being used with functions to capture different aspects of the date: day, month, and year. The final event transform is a reference of the upstream actions' values.

Refactoring: Instead of calculating each date piece in individual actions, we use that same series of functions in the fourth "Total Info" action. Once consolidated, we are left with the same end results of day/month/year within one action, instead of across four.

Reducing actions with functions

In this video, we'll see how we replace multiple actions by using a Tines function instead. We look at an existing story that utilizes explodes, implodes, and a trigger action to check an array of spells returned from an HTTP request action and see if the "Feast" spell is included in the array.

Refactoring: Instead of building out this logic through multiple actions, this can be done using the INCLUDES function, which returns TRUE if the target includes the specified value. Also, putting TEXT right before the array makes it easier to check the array with INCLUDES. We build this into a trigger action to handle both TRUE and FALSE scenarios, if needed.

Review the results

We optimize these stories by reducing the total count of action tiles on the storyboard. It's also easier to troubleshoot as all of the formula logic is within one action.

Did this answer your question?