I forget the name of it but there’s a rule that you aren’t supposed to allow visibility into an objects inner makeup. It has to do with not allowing more than one dot in the implementation like this for example:
return world = foo.bar.hello.world();
7
It’s part of the Law of Demeter. http://en.wikipedia.org/wiki/Law_of_Demeter
The Law of Demeter (LoD) or principle of least knowledge is a design guideline for developing software, particularly object-oriented programs. In its general form, the LoD is a specific case of loose coupling. The guideline was proposed at Northeastern University towards the end of 1987, and can be succinctly summarized in one of the following ways:[1]
- Each unit should have only limited knowledge about other units: only units “closely” related to the current unit.
- Each unit should only talk to its friends; don’t talk to strangers.
- Only talk to your immediate friends.
The fundamental notion is that a given object should assume as little as possible about the structure or properties of anything else (including its subcomponents), in accordance with the principle of “information hiding”…
1