Feature flags

Did you ever implement a large feature and when release you merge it into the release branch? And if you only want only some people can use the new feature to evaluate the effectiveness of the feature. Or the marketing team wants to test a certain behavior. You need a switch to do that.

Today I will introduce a technical called Feature Flags.

1. What are Feature flags?

Feature flags are a technical use flag to turn on or off some features in our app. It allows us to change system behavior.

So how many types of Feature flags?

I think it has 2 primary types: Static Feature Flag and Dynamic Feature Flag.

2. Types of feature flags

2.1 Static Feature Flags

A static feature flag is simple in that we define a struct, a variable with hard fix values, or write to the config file. So, we will use the variable to control system behavior.

struct FeatureFlags {
    static let fastExportFeature = true // Define flags cho feature

It has cons is when we want to change the flag, we need to recompile. So, Dynamic feature flags were born.

2.2 Dynamic Feature Flags

Don’t like static, Dynamic Feature Flags help we turn on or off feature without recompiling the app.

We can construct a hidden screen contain switches to perform update flags. Like a company I work for is Cốc cốc, they inheritance feature flags screen from Chromium by go to address coccoc://flags.

Besides, We can use other 3rd services to support turn-on or off features from servers. Like featureflags.io, rollout.io, or firebase remote config.

3. Pros and Cons of Feature Flags


  • Help us easy to try the new feature in the development stage.
  • Easy A/B testing by control feature flags to control behavior.
  • Allow us to merge small pieces of code to the master branch easily.
  • Allow us easy release new features to only some users.
  • The development stage will be faster.
  • Reduce risk when releasing new features.


  • We must if-else many times.
  • Only relevant when developing the large features.
  • Must test carefully to ensure new code doesn’t run when flags are off.

Learn more:

Leave a Reply