Skip to main content

Stop reaching through objects

Replace a message chain with a boundary that hides internal object structure.

clean-code-principles5 min read

Message chain order.customer.account.billingProfile.address.country leaked the customer object graph into tax policy. When the graph changed, unrelated services broke because they depended on structure instead of concept. Coupling rule Law of Demeter + Information Hiding Reduce knowledge of distant object structure. Hide the volatile path behind a stable concept the caller can ask for directly. Reach Walk through five objects to find one field. Tax policy depends on TaxContext, not billing-profile storage. Callers should depend on the concept they use, not the path used to retrieve it. 01 Need 02 Boundary 03 Review First decision Tax code currently reads one nested…

Read the full lesson

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

← Back to library

Contact us