Principles
Law of Demeter: Break the Getter Chain
The Law of Demeter says a method talks to its own fields, its parameters and the objects it creates, and not to the objects those hand back. A long getter chain breaks it, so one change deep inside a class breaks every caller that walks the chain. These lessons hide the delegate step by step until each caller talks only to the object it was given.
Pick your language
When to use it
Use it when
A class reaches through one object to get at another one's data, in more than one place.
Skip it when
The chain is a builder or a stream that returns a type you already use, or the objects are plain data records.
Spot it by
A line with several getters in a row, each called on what the last one returned.