Skip to main content
CLEAN-CODE-PRINCIPLES5 MIN READ

Bundle data that travels together

Introduce a parameter object when repeated parameters form one domain concept.

A pricing function takes seven parameters, and several callers pass them in different orders. The next rule needs another pricing fact. Introduce Parameter Object when a set of parameters forms a cohesive domain concept that travels together. The trap is creating a vague Options bag that accepts every future value and hides which data is required. Before priceQuote(cart, plan, region, currency, taxId, contractStart, salesChannel, discountCode) After priceQuote(cart, quoteContext, discountCode) QuoteContext = { plan, region, currency, taxId, contractStart, salesChannel } Find repeated travel Look for the same parameter cluster appearing in multiple calls. Repeated travel is evidence of a missing concept.…

Read the full lesson

Sign up free — one personalized lesson every day, matched to your role and goals.

Already have an account? Sign in

← Back to library
Contact us