Week #15 2022 - Feature Flags
Feature Flags
Feature Flag is a technique in software development to switch on or off a feature based on specific conditions. Many scenarios can take advantage of Feature Flags. These are a few samples of them:
- You want to test feature changes in the non-production environments only. They shouldn’t be functional in the production until you’re sure it satisfies all requirements.
- You want some features to be active in a specific region only.
- You want to do A/B testing on a feature for a subset of users.
- You want to show advanced features to the pro subscribers only.
In the trunk-based development, where every code change is directly pushed into the main branch, Feature Flags are one of the critical components that make the technique works. It makes the same code base can be deployed to different environments automatically, but with different behaviors depending on the Feature Flags setup.
However, please be aware that using Feature Flags excessively on an application could create a technical debt pitfall over time. They often get forgotten as the development team pivot toward new business deliverables. It is not uncommon to find that a development team just has no idea of the purpose of a config value when maintaining a legacy application. The safest thing to do is to keep it untouched with the default value at all times.
Let’s see what are the best practice to implement the Feature Flags then:
- Make flag planning part of the feature design. It means that Feature Flags shouldn’t be an afterthought. You need to decide in advance if the flag will be a short-term or permanent flag.
- Standardize the naming. It should be easy enough to know what the flag is doing just by reading the name. The developer who maintains the application in the future will thank you for this effort.
- Minimize the reach of the flags. The focus of a flag should be small. Having a flag that controls more than one feature action at a time can be confusing and will make troubleshooting harder.
- Review the usage regularly. Please don’t assume it will sit on the code base forever once you create a flag, even for the “permanent” ones. Otherwise, it will quickly give you a technical debt trap in the future. The frequency at which you review the flags may vary based on the business requirements.
We have implemented Feature Flags in many of the Polyrific projects. Let’s take the example from the Go Wandering application, we used Feature Flags to:
- be able to switch databases between Cosmos DB and SQL Server
- be able to switch mailing providers between SMTP and SendGrid
- disable/enable the Facebook and Google login
- disable/enable ReCaptcha
- disable/enable content moderation/profanity filter
- and many more
Tech News
The twelve-factor app, a comprehensive best practice for developing SaaS apps (Read the summary and the detail of all the twelve factors here)
Brain: “The developers at Heroku share this document that synthesizes all of their experience and observations on a wide variety of software-as-a-service apps in the wild. It covers things from how to manage your codebase, dependencies, CI/CD, to how to treat logs in your application. I think it’s quite insightful for those who try to create such applications, whether for developers or ops engineers”.
The end of the road for Cloudflare CAPTCHAs (Read how Cloudflare tries to put an end to captcha)
Brain: “Interesting article that tells us about why we still have to deal with Captcha in this world, and the trade-off companies need to make to eliminate CAPTCHAs. It turns out something that looks as simple as CAPTCHAs requires many solutions for it to be replaced”.
OpenAI’s DALL-E AI is becoming a scary-good graphic artist (Read the story about the latest OpenAI experiment)
Brain: “I didn’t expect such highly creative work could be threatened by AI this soon. But with DALL-E, it seems like you can have your own artist who you can just describe what you want, and it’ll create the illustration for you. I mean look at how it can create the picture with quite a particular description”.
How to prevent email HTML injection in C# and .NET (Read the technical tutorial here)
Brain: “For our dotnet programmer, this article is good at explaining how we can prevent email HTML injection when we develop an application that has a feature to send an email. This is especially useful when the website is a public site that can be used by any user, including some malicious ones”.
Introducing the new Azure Front Door: Reimagined for modern apps and content (Read the new features of Microsoft’s enterprise CDN)
Brain: “Microsoft announced a new Azure Front Door, with new features that also include CDN capabilities in addition to the existing traffic management & load balancing feature. It also offers a simplified cost model which makes it easier for us to budget our resources. The previous product of Azure Front Door and Azure CDN will now be known as Azure Front Door (classic) and Azure CDN from Microsoft (classic) moving forward”.