Feature flags enable dynamic control over new features without redeploying applications. They allow testing in production, gradual rollout, and safe rollback.
class FeatureFlag:
def __init__(self):
self.flags = {}
def set_flag(self, name, state):
self.flags[name] = state
def is_enabled(self, name):
return self.flags.get(name, False)
# Usage
feature_flags = FeatureFlag()
feature_flags.set_flag("new_ui", True)
if feature_flags.is_enabled("new_ui"):
print("New UI is enabled")
else:
print("New UI is disabled")
const { LDClient } = require('launchdarkly-node-server-sdk');
const ldClient = LDClient.init('SDK_KEY');
ldClient.waitForInitialization().then(() => {
const showFeature = ldClient.variation('new-feature-flag', { key: 'user123' }, false);
if (showFeature) {
console.log('Feature enabled for user');
}
});
import no.finn.unleash.DefaultUnleash;
import no.finn.unleash.Unleash;
import no.finn.unleash.strategy.Strategy;
import no.finn.unleash.util.UnleashConfig;
UnleashConfig config = UnleashConfig.builder()
.appName("my-app")
.instanceId("instance-1")
.unleashAPI("http://unleash-server/api/")
.build();
Unleash unleash = new DefaultUnleash(config);
boolean isEnabled = unleash.isEnabled("new-feature-flag");
if (isEnabled) {
System.out.println("Feature is enabled");
} else {
System.out.println("Feature is disabled");
}
Feature flags provide flexibility, safe rollouts, and testing in production, empowering DevOps teams to release faster and reduce risk.