Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a feature flag in software development?
A feature flag is a toggle that allows developers to turn features on or off without deploying new code. It helps control feature rollout and testing in production.
Click to reveal answer
intermediate
How do feature flags help in microservices architecture?
Feature flags enable independent control of features in different microservices, allowing gradual rollout, A/B testing, and quick rollback without redeploying services.
Click to reveal answer
intermediate
What are common types of feature flags?
Common types include: 1. Release flags - control new features rollout. 2. Experiment flags - for A/B testing. 3. Ops flags - for operational control like disabling features during outages.
Click to reveal answer
advanced
What is a key challenge when using feature flags in distributed systems?
Ensuring consistent flag state across all microservices and avoiding stale or conflicting flag values is a key challenge in distributed systems.
Click to reveal answer
beginner
Why should feature flags be removed after use?
Old feature flags add complexity and technical debt. Removing them keeps code clean and reduces risk of unexpected behavior.
Click to reveal answer
What is the main purpose of a feature flag?
ATo manage database connections
BTo store user data securely
CTo monitor system performance
DTo toggle features on or off without redeploying code
✗ Incorrect
Feature flags allow toggling features without new deployments.
Which type of feature flag is used for A/B testing?
ARelease flag
BOps flag
CExperiment flag
DSecurity flag
✗ Incorrect
Experiment flags enable A/B testing by controlling feature exposure.
What is a common risk of not removing old feature flags?
AIncreased technical debt
BReduced code complexity
CImproved system performance
DBetter feature rollout
✗ Incorrect
Old flags increase technical debt and complexity.
In microservices, what is a challenge when using feature flags?
AEnsuring consistent flag state across services
BWriting SQL queries
CManaging user authentication
DScaling database storage
✗ Incorrect
Distributed systems must keep flag states consistent to avoid errors.
Which feature flag type helps disable features during outages?
ARelease flag
BOps flag
CExperiment flag
DSecurity flag
✗ Incorrect
Ops flags control operational aspects like disabling features in emergencies.
Explain how feature flags improve deployment and testing in a microservices environment.
Think about how toggling features helps avoid full redeployments.
You got /5 concepts.
Describe best practices for managing feature flags to avoid technical debt.
Consider how old flags affect code quality.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of using feature flags in microservices?
easy
A. To increase database storage capacity
B. To enable or disable features without deploying new code
C. To improve network bandwidth
D. To encrypt communication between services
Solution
Step 1: Understand feature flags concept
Feature flags allow toggling features on or off dynamically without changing the codebase.
Step 2: Identify the main benefit in microservices
This helps in testing, gradual rollout, and quick disabling of features without redeployment.
Final Answer:
To enable or disable features without deploying new code -> Option B
Quick Check:
Feature flags = toggle features dynamically [OK]
Hint: Feature flags toggle features without code changes [OK]
Common Mistakes:
Confusing feature flags with database scaling
Thinking feature flags improve network speed
Assuming feature flags handle encryption
2. Which of the following is the correct way to check a feature flag named new_ui_enabled in a microservice?
easy
A. featureFlags.enable('new_ui_enabled')
B. if (featureFlags.check('new_ui_enabled') == false) { /* use new UI */ }
C. if (featureFlags.isEnabled('new_ui_enabled')) { /* use new UI */ }
D. featureFlags.remove('new_ui_enabled')
Solution
Step 1: Identify correct method to check flag status
Checking if a feature flag is enabled usually uses a method like isEnabled returning true or false.
Step 2: Analyze options
if (featureFlags.isEnabled('new_ui_enabled')) { /* use new UI */ } correctly checks if the flag is enabled before using the feature. if (featureFlags.check('new_ui_enabled') == false) { /* use new UI */ } incorrectly uses check and false condition. featureFlags.enable('new_ui_enabled') and featureFlags.remove('new_ui_enabled') modify flags, not check them.
Final Answer:
if (featureFlags.isEnabled('new_ui_enabled')) { /* use new UI */ } -> Option C
Quick Check:
Check flag with isEnabled() = if (featureFlags.isEnabled('new_ui_enabled')) { /* use new UI */ } [OK]
Hint: Use isEnabled() to check feature flags status [OK]
Common Mistakes:
Using enable() or remove() to check flags
Checking flag with wrong method or negation
Confusing flag check with flag update
3. Consider this pseudocode snippet in a microservice:
What will be the output if the flag beta_feature is set to false?
medium
A. Beta feature inactive
B. Beta feature active
C. Error: flag not found
D. No output
Solution
Step 1: Understand flag value effect on condition
The condition checks if beta_feature is enabled (true). If false, it goes to else branch.
Step 2: Determine output when flag is false
Since the flag is false, the else block executes returning 'Beta feature inactive'.
Final Answer:
Beta feature inactive -> Option A
Quick Check:
Flag false triggers else = Beta feature inactive [OK]
Hint: False flag runs else block output [OK]
Common Mistakes:
Assuming false flag runs if block
Expecting error when flag is false
Ignoring else branch output
4. A developer wrote this code to disable a feature using a feature flag:
if (featureFlags.isEnabled('dark_mode')) {
disableDarkMode();
}
Why might this code not work as intended?
medium
A. It disables dark mode when the flag is enabled, which is opposite logic
B. The method disableDarkMode() does not exist
C. Feature flags cannot control UI features
D. The flag name should be 'enable_dark_mode'
Solution
Step 1: Analyze the condition logic
The code disables dark mode if the flag is enabled, which is opposite of expected behavior (usually enabled flag means enable feature).
Step 2: Identify correct logic for disabling feature
To disable dark mode when flag is false, the condition should check if flag is disabled or negate the check.
Final Answer:
It disables dark mode when the flag is enabled, which is opposite logic -> Option A
Quick Check:
Enabled flag should enable, not disable [OK]
Hint: Enabled flag usually means feature ON, not OFF [OK]
Common Mistakes:
Confusing enable and disable logic
Assuming flag controls only backend features
Using wrong flag names without checking
5. You want to roll out a new payment feature gradually using feature flags in a microservices system. Which design approach is best to ensure minimal impact and easy rollback?
hard
A. Disable all other microservices during rollout to avoid conflicts
B. Deploy new code with feature always enabled and monitor logs manually
C. Hardcode feature flag values in each microservice and update code to change flags
D. Use a centralized feature flag service with percentage rollout and fallback to old payment service
Solution
Step 1: Understand gradual rollout with feature flags
Gradual rollout means enabling feature for a small percentage of users first, then increasing over time.
Step 2: Identify scalable and safe design
A centralized flag service allows dynamic control and percentage rollout. Fallback ensures quick rollback if issues arise.
Step 3: Evaluate other options
Deploy new code with feature always enabled and monitor logs manually lacks control and rollback ease. Hardcode feature flag values in each microservice and update code to change flags requires code changes for flag updates, not scalable. Disable all other microservices during rollout to avoid conflicts is disruptive and unnecessary.
Final Answer:
Use a centralized feature flag service with percentage rollout and fallback to old payment service -> Option D
Quick Check:
Centralized flags + gradual rollout = Use a centralized feature flag service with percentage rollout and fallback to old payment service [OK]