(ref.doc)enag 020194

Next jbuck 030194 Prev: oreilly 061293 Up: Usenet

From: [email protected] (Erik Naggum)
Newsgroups: comp.std.c++
Subject: Re: STOP! You MUST use 'p' and 'r'!
Date: 02 Jan 1994 00:17:06 GMT
Organization: Dept. of Informatics, University of Oslo, Norway
NNTP-Posting-Host: gyda.ifi.uio.no

[Craig Larman]

|   Suddenly I discerned a subtle vibration filling the void*.
|   Was it the Cosmic OM? "I" listened closer - Lo! it was 
|   
|     Use 'p' and 'r' in pointer and reference variable names,
|     Use 'p' and 'r' in pointer and reference variable names...
|   
|   "I am appointing you the demigod (or was it demagogue?) of
|   C++ style on Earth. Please spread this wholesome and skillful
|   message of variable naming. It will save untold hours in
|   debugging, thus freeing up programmers time to spend in
|   deep meditation. For example:
|      void FooBar(const Person *pPer);
|      void FooBar(const Person &rPer);"

As the * and & become redundant, "const" can be reduced to an initial "c"
in the name, class names can prefix the variable name, and we can do away
with those complex type specifications, altogether.  const Person *per
would become cpPerson_per, and void FooBar (const Person *per) could become
fv_cpPerson_FooBar (per).  This will do away with the need to remember the
type of _any_ object.  Then operators could include the type prefix of
their arguments so debugging would become even easier.  Never mind that
writing code that does not _need_ debugging in the first place will become
next to impossible.

Pointers and references are not trivial for new programmers, but what
better to wish for than that educators instruct so that people can walk
without crutches?  It is disturbing that C++ teachers receive revelations
from the Eternal Bug and are unable to distinguish good from bad.

The suggested scheme is harmful because it instills a false sense of
security in its users, and cripples their ability to read code that does
not use this scheme.  Bugs will be bugs.

As a professional programmer since 1985 and an occasional instructor, I
have found that there is no substitute for reading when one wants to write,
and that exposing students to large amounts of code will more quickly teach
style and consistency than any book of rules and conventions thrown at
them.  Even the American public schools, brain-damaging as they are, do not
suggest that first-graders get a "hands-on experience" with writing before
they have learned the alphabet, and do not prefix words with abbreviations
for parts of speech, not even as a temporary aid before learning to parse.

Best regards,
</Erik>

--
Erik Naggum <[email protected]> <[email protected]>        Memento, terrigena.
ISO 8879 SGML, ISO 10744 HyTime, ISO 10646 UCS        Memento, vita brevis.


automatically generated by info2www version 1.2.2.8