World’s most extensive transportation network company, Uber has been engaged in powerful developing techniques to produce an excellent user experience. Uber has been using feature flags to customize the mobile app execution, which serves various features to different sets of users. These feature flags help in localising the user’s experience in several operating regions also as help to roll-out features to our users and experiment with different variations of a similar functionality.
According to the researchers at Uber, in such cases, after any successful also as unsuccessful rolling out of any features to the users, the feature flag within the code becomes obsolete or stale.
At Uber, we use feature flags to customize our mobile app execution, serving different features to different sets of users. These flags allow us to, as an example, localize the user’s experience in several regions where we operate and, more importantly, to gradually roll-out features to our users and experiment with different variations of a similar functionality.
However, after a feature has either been 100 percent extended to our users or an experimental feature has been deemed unsuccessful, the feature flag within the code becomes obsolete. These non-functional feature flags represent technical debt, making it difficult for developers to figure on the codebase, and may bloat our apps, requiring unnecessary operations that impact performance for the top user and potentially impact overall app reliability.
Removing this debt are often time-intensive for our engineers, preventing them from performing on newer features.
Seeking to automate this process, we developed Piranha, a tool that scans source code to delete code associated with stale, or obsolete, feature flags, resulting in a cleaner, safer, more performant, and more maintainable code base. We run Piranha at Uber in an ongoing pipeline for our Android and iOS codebases, and have used it to get rid of around two thousand stale feature flags and their related code.
We believe Piranha offers great utility for organizations that use feature flags in their app deployments, then have open sourced it. Currently implemented for Objective-C, Swift, and Java programs, open source contributors might want to use Piranha to other languages or improve on its ability to perform deep code refactoring’s.
Piranha may be a tool that automatically refactors code, which are associated with stale flags. This tool is an automatic source-to-source code refactoring tool, which is employed to automatically generate differential revisions to delete code like outdated feature flags. Consistent with developers, this tool provides excellent utility for organisations that use feature flags in their app deployments.
Currently, Piranha supports Objective-C, Swift, and Java programs. Piranha Java refactors stale feature flag-related code in Java applications, specifically those targeting the Android platform. Piranha Swift is implemented in Swift language using Swift Syntax for refactoring Swift code and, Piranha ObjC is employed to wash up code in Objective-C programs and is implemented in C++. The developers identified three critical dimensions for performing the code clean-up, which are Code that immediately borders the feature flag APIs Code that becomes unreachable because of completing the above step. This step is additionally referred to as deep cleaning.
Delete tests associated with feature flags.
Piranha may be a tool to automatically refactor code associated with stale flags. At a better level, the input to the tool is that the name of the flag and therefore the expected behaviour, after specifying an inventory of APIs associated with flags during a properties file. Piranha will use these inputs to automatically refactor the code consistent with the expected behaviour.
This repository contains three independent versions of Piranha, one for every of the three supported languages: Objective-C, Swift, and Java.
To use/build each version, look under the corresponding [Lang]/ directory and follow instructions within the corresponding [Lang]/README.md file. confirm to cd into that directory to create any related code following the instructions within the README.
Piranha the way to remove obsolete code? It also starts with a typical for Uber code.
In order to facilitate the event of system updates, Uber has adopted a feature flag, also referred to as a function switch. this is often a way that permits online functions to be controlled on or off. it’s widely utilized by major Internet companies.
Using this method has many advantages. It can complete new function tests then publish them as fully available. It also can customize differentiated services (A / B testing) for various users, and support rollback when bugs occur. Engineers also can remotely disable the faulty a part of the appliance.
According to reports, there are over 6000 function marks altogether Uber’s program code base.
But the rise of the function flag also will increase the complexity of the code base. Once the flag is out of date, you would like to delete it, otherwise it’ll bring a technical burden.
Automatically detect and delete with Piranha.
Specifically, Piranha must automatically detect obsolete signs and delete their associated code. the problem of this process is to work out whether the sign is used by someone, the owner of the sign, and understand the precise details of the code.
Considering Piranha’s application background, Uber uses application static analysis, which may be a code review to seek out obsolete code left over from obsolete signs.
The three key dimensions which will be cleaned up are:
Using feature flags, companies like Uber can localize the user experience in several regions they operate. It helps Uber and other companies gradually roll-out features to users across the globe, and experiment with different variations of an equivalent functionality.
Now, these feature flags either become a successfully implemented feature or just become an unsuccessful attempt. In either case, the feature flag isn’t relevant anymore and turns into a stale feature flag.
That is precisely where developers need Piranha. This open-source tool can automatically delete these feature flags that are not any longer needed, alongside their corresponding code. Obsolete code like stale feature flags not only creates clutter within the codebase and increase its complexity but also interferes with other flags or cause bugs sometimes.
The flag management system periodically sends a list of probably stale flags to Piranha, which generates a diff and sends it to the first flag author. The author can then determine whether to land the diff.
Of course, within the introduction above, to use Piranha, the code must meet the subsequent conditions:
Uber says it as used Piranha to get rid of around two thousand stale feature flags and their related code. The corporate recommends using Piranha in applications that use feature flags extensively and implement specific APIs to regulate their behaviour.
To read more about Piranha, you’ll ask the Uber blog and obtain it on GitHub.