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

Re: Law of good style for CLOS

>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.    

If a class is defined with accessor generic functions whose names are
exported from the package, but are different from the slot names,
which are not exported (or "hidden"), then the only access to the
slots is through a functional interface. From the client's point of
view, invoking a generic function on the object need not have any
relation to slot access at all, much less an inherited or noninherited
slot. This is an even stronger form of encapsulation, since the structure
of the class is now completely hidden. Of course, an inheriting client
may still want access to that structure.