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

name for SEFTable

Date: Wed, 25 Oct 89 08:25:27 PDT
   From: michael (Michael McClary)

   markm>    (note that we can't say ConstX,
   markm>    because that isn't symmetrical with our other names),

   How is this asymmetrical?

Recall our other table names: ImmuTable, MuTable, ScruTable.
ConsTable is a similar pun.  ConstTable isn't.  Admittedly, symmetry
in nature of pun may be a novel software engineering principle, but is
just as valuable.  The nice thing about a symmetrical naming
convention is that it reduces the cognitive size of the name space
from N * M to N + M (or something like that).

   tribble> (For a class to deserve the name
   tribble> const, all member functions defined for it should be declared
   tribble> 'const').

   No.  For a class to deserve the name "const", it should be impossible to
   change the (apparent) state of the object once it has been constructed.
   This does not necessarily mean that variables, member functions, arguments
   to member functions, or anything else associated with the object (except
   public variables, which we try to avoid) should be declared "const".  It
   just means no public member functions change the object's state memory.

    ConsTable *const p = ....;
    .... p->foo() ....;

Given that "foo()" is declared as a message of ConsTable, I'd expect
the above to work.  Note that it will only if ConsTable::foo() is
declared to be "const".  I think that should eventually be done for
all ScruTable/ConsTable member functions, but until it is, let's stick
with ScruTable.  Besides, I think ScruTable is cuter.

   ... As I read the manuals, the meaning of
   "const" is "It is an error to try to change the state of this thing."
   I get that from "immutable" as well.  

More accurately, it is an error for *you* to change the state of this
thing.  Even more accurately, it is an error for you to change it
though a const reference to it.  It can still be changed through other
paths, and you will see those changes through your const reference.
This means "const" corresponds to read-only.  ImmuTable on the other
hand is a guarantee that it will not be changed by you or anyone else.

   From "scrutable" I get "You can
   understand this thing." which stretches to "You can read it."  but doesn't
   reach "You can't change it.".

Good point.