--- title: Feature flags should be short-lived date: 2024-03-11 permalink: daily/2024/03/11/feature-flags-should-be-short-lived tags: - software-development - feature-flags cta: subscription snippet: | Feature flags should be short-lived. Once the change has been released, the flags should be removed. --- Today, I [posted a tweet][tweet] with a screenshot of some code. When previously working on the [Versa CLI tool][versa], I had a TODO comment saying "What if there are multiple languages?". Versa is a tool for standardising commands between different languages and frameworks, but some projects, like my personal website, use multiple languages. The website is powered by Sculpin, a static site generator written in PHP (so there is a composer.json file) and node to compile the front-end assets (so there is also a package.json file). ## What Problem Am I Trying to Solve? Depending on the language, commands like `versa install` will need to execute a different command - e.g., composer install` or `npm install` (or an equivalent node package manager). I added PHP support first, so if a composer.json file is found, the PHP command is run as the default. What I thought was for projects with multiple languages, to prompt the user to select the language when running the command if no explicit language is set. This led me to do a spike of using Symfony Console's `choice` method to see what that would look like so I could add a screenshot to the GitHub issue. Once I'd finished with the spike, rather than deleting the code, I wrapped it in an `if (false)` condition so it wouldn't be executed, but I could still re-enable it in the future. The screenshot in the tweet showed this, along with the text "Minimum viable feature flag." This is only supposed to be there for a short time until I revisit the code and implement the feature I was spiking on. If it would be a long time before I looked at it again, I'd take a different approach. ## Here's the Thing One of the main rules of using feature flags is that they should be short-lived. It's less than ideal to read through a codebase and see it scattered with feature flags that are no longer needed and were used to release a feature several months ago, but the flag hasn't been removed. A feature flag is a temporary solution for separating the deployment of code from the release of a change. Once it's been released, the flag should be removed. [tweet]: https://twitter.com/opdavies/status/1767846980250714261 [versa]: {{site.url}}/daily/2024/02/19/introducing-versa