Performance: Feature flags concept
MEDIUM IMPACT
Feature flags affect application startup time and runtime decision-making speed, impacting how fast features are enabled or disabled without redeploying.
private final Map<String, Boolean> featureCache = new ConcurrentHashMap<>();
public boolean isFeatureEnabled(String feature) {
return featureCache.computeIfAbsent(feature, this::loadFeatureFlag);
}
private boolean loadFeatureFlag(String feature) {
return jdbcTemplate.queryForObject("SELECT enabled FROM feature_flags WHERE name = ?", Boolean.class, feature);
}public boolean isFeatureEnabled(String feature) {
// Reads from database on every call
return jdbcTemplate.queryForObject("SELECT enabled FROM feature_flags WHERE name = ?", Boolean.class, feature);
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Database call per flag check | 0 | 0 | 0 | [X] Bad |
| In-memory cached flag check | 0 | 0 | 0 | [OK] Good |