[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Law and documentation
- To: commonloops.pa@Xerox.COM
- Subject: Law and documentation
- From: karl lieberherr <firstname.lastname@example.org>
- Date: Mon, 27 Jun 88 08:24:23 EDT
- Redistributed: commonloops.pa
John Berger has the following comments:
>Concerning the Law: You say that function calls inside a method M
>should use only certain objects as method selection arguments.
>How does the programmer know what arguments a function will use to
>dispatch according to type? How does the programmer know that a
>function is generic and will do such a dispatch?
When the programmer writes a function call, he/she has to know how the system
will locate the code to execute (otherwise the wrong code might get executed).
>You say the Law prohibits functional composition of accessor functions
>which return non-slot objects.
>How does the programmer know that a function-call is a slot-access?
If you request a reader or accessor, CLOS will generate such a function
for you. You can do it also with slot-value.
>You say it's okay to use objects that are created by the method in
>question, or by a function that it calls.
>How does the programmer know that an object returned by a function is
It is standard to distinguish between constructors, mutators and observers
(see Liskov and Guttag, Abstraction and Spec. in Progr. Dev., page 90).
I consider it good practice to consider it as part of the type of a method
whether it is a constructor or not.
>It seems that in order to use the Law, the programmer must have
>knowledge which violates an even older law: That of information-hiding.
No. The Law of Demeter promotes information restriction (in a given method
you can only call certain other methods). The concepts of information
restriction and information hiding are orthogonal to each other and both
have been proposed originally by Parnas. It is true that the Law requires you
to keep track of certain information, but you need that information anyway to
understand the method you are writing. It is excellent documentation to
your program. -- Karl