Bird
0
0

A developer wrote this code to disable a feature using a feature flag:

medium📝 Analysis Q14 of 15
Microservices - CI/CD for Microservices
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?
AIt disables dark mode when the flag is enabled, which is opposite logic
BThe method disableDarkMode() does not exist
CFeature flags cannot control UI features
DThe flag name should be 'enable_dark_mode'
Step-by-Step Solution
Solution:
  1. 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).
  2. 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.
  3. Final Answer:

    It disables dark mode when the flag is enabled, which is opposite logic -> Option A
  4. Quick Check:

    Enabled flag should enable, not disable [OK]
Quick Trick: 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

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes