Object Form of Law of Demeter
"Do not talk to strangers".
Within a method, messages can only be sent to the following objects:
-
1. A parameter of the method, including the enclosing object (this or self);
-
1.1. For pragmatic reasons: a global object;
-
2. An immediate part object (computed or stored):
-
2.1 An object that a method called on the enclosing object returns,
including attributes of the enclosing object;
-
2.2 An element of a collection which is an attribute of the enclosing object;
-
3. An object created within the method.
Checking the Object Form of the Law of Demeter
using an adaptive AspectJ program.