The law of demeter is an attempt to limit the way in which one component can interact with another component.
Law of Demter. In any Method M attached to a class C, only methods defined by the following classes may be used:
- 1.
- The instance variable classes of C.
- 2.
- The argument classes of method M (including C); note that global objects or objects created inside the method M are considered arguments to M.