[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Law of good style for CLOS

	    ----- LAW OF DEMETER FOR CLOS (object version)----------
	    All function calls inside a method M must have
	    one of the following objects passed by their first argument:
	        a value of M's parameters or
	        an immediate part (the value of a slot) of the first argument.
	    (Objects created by the method and objects in global 
	     variables are viewed as being passed by arguments.)
Dan Carnese proposes the following violation:
	(defmethod violation ((l demeters-law))
	  (format t "How about this?"))
We view here t as an object passed by a global variable and therefore
this method is in good style.

As other man-made laws, the Law of Demeter allows room for 
interpretation. For example, if we interpret "immediate part" as
the value of a slot which is declared for the given class (parameter
specializer of first argument) and not a value of an inherited
slot, we have a more restricted version of the Law (called the
strong Law) which has been studied in some of Alan Snyder's papers
on encapsulated software systems.     -- Karl Lieberherr