Following References

It's often good to be able to refer to primary sources. I came across one such reference this morning for the Law of Demeter

For all classes C, and for all methods M attached to C, all objects to which M sends a message must be

  • M's argument objects, including the self object or
  • The instance variable objects of C.

(Objects. created by M, or by functions or methods which M calls, and objects in global variables are considered as arguments of M.)

That's an OOPSLA paper from 1988, with references going back further, notably to work by Parnas on decomposition into modules.

The Law of Demeter, when used in coordination with three key constraints, enforces good programming style. These constraints require minimizing code duplication, minimizing the number of arguments passed to methods and minimizing the number of methods per class.