Code AnalysisHard 60s
Wrong abstraction refactor
def render_price(item, currency_type, is_digital, is_bundle, apply_tax):
if currency_type == 'USD':
base = item.usd
elif currency_type == 'EUR':
base = item.eur
if is_digital and not is_bundle:
base -= 5
if is_bundle and apply_tax:
base = base * 1.1
elif is_bundle and not apply_tax:
base = base
return base
# callers pass is_digital/is_bundle flags in many combinations
Callers keep passing flag combinations that grow over time. What refactor best addresses this?
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.