Message Chains

Referenced by patterns
Symptom

Long dotted access paths: a.b.c.d.e — every callsite walks the entire object graph.

Goal

Callers ask the closest object for what they want; the object delegates internally.

Smellier version

const street = order.customer.address.street;

Fresher version

const street = order.customerStreet();
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure

Every link in the chain is a coupling point; renaming any intermediate field breaks every consumer.

Tradeoff

Hiding the delegate adds a passthrough method on the host class for every chained operation; if the chain is used in only one place, the passthrough is pure ceremony.

Relief

Encapsulation tightens; intermediate objects can change shape without breaking callers.

Trap

Wrapping every dotted chain in passthrough methods — the chains migrate from call sites into the host class's surface, which then balloons with delegations that add no real value.