NOTE

Law of Demeter

Reducing knowledge of distant object structure and avoiding brittle navigation through internal collaborators.

Software Architecture & EngineeringCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

The Law of Demeter encourages an object to collaborate through nearby, intentional interfaces rather than reaching through chains of internal objects such as a.getB().getC().doX().

The deeper goal is encapsulation: callers should ask an abstraction to perform a meaningful operation instead of knowing its internal object graph. Apply it pragmatically; simple immutable data traversal is not automatically a design smell.

Loading helpful count