home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / software / 4907 < prev    next >
Encoding:
Internet Message Format  |  1992-12-12  |  3.7 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!swrinde!gatech!concert!borg!news_server!martinc
  2. From: martinc@hatteras.cs.unc.edu (Charles R. Martin)
  3. Newsgroups: comp.software-eng
  4. Subject: Re: C code Layout
  5. Message-ID: <MARTINC.92Dec12155025@hatteras.cs.unc.edu>
  6. Date: 12 Dec 92 20:50:25 GMT
  7. References: <1992Dec12.122453.8582@seq.uncwil.edu>
  8.     <1992Dec12.200619.29602@fcom.cc.utah.edu>
  9. Sender: news@cs.unc.edu
  10. Organization: UNC Department of Computer Science
  11. Lines: 65
  12. In-reply-to: bryant@ced.utah.edu's message of 12 Dec 92 20:06:19 GMT
  13.  
  14. In article <1992Dec12.200619.29602@fcom.cc.utah.edu> bryant@ced.utah.edu (Bryant Eastham,MEB 3116,581-5353) writes:
  15.  
  16.  
  17.    In article 8582@seq.uncwil.edu, herbst@seq.uncwil.edu (R.T. Herbst) writes:
  18.    >While directing the eforts of 125 people in producing the 
  19.    >A Data switching system for the Bell System- Good ol'
  20.    >Ma bell-- I asked for a sample of code. I founr the comments to
  21.    >be utter nonsense,. If one removed the code, the comments made no sense.
  22.    >It was better to let the code speak for itself. If fact the code
  23.    >was hidden in by the comments. Certainly we need well commented code.
  24.    >Too many comments that try to say what the code is saying are IMHO
  25.    >distracting. 
  26.  
  27. Useless verbiage is useless verbiage, no question.  Comments need to be
  28. directed toward producing insight in the code, not to meeting a
  29. percentage standard or some such.  So to this extent, Herbst and I can
  30. agree. 
  31.  
  32. On The Other Hand -- I don't see how reducing the number of comments to
  33. the block comment at top sort of standard can solve this: if the
  34. comments there are misleading, verbose, or wrong you're in just as much
  35. trouble.  The points seem to be orthogonal -- no number of BAD comments
  36. help clarity.  On the other hand, too few good comments don't help
  37. clarity much.
  38.  
  39. Now, then, as Brian says --
  40.  
  41.    Anyone can get lucky a couple of times. ;-)
  42.  
  43.    If you believe that K&R is "about right", then we will never
  44.    come to agreement on what the right amount of comments is.
  45.  
  46. Trying to use K&R as a standard for code commenting is a bad mistake,
  47. flawed by the assumption that the code in K&R in any way stands alone.
  48. Examination of the text itself shows that the code does *not* stand
  49. alone; for example, the description of basic I/O in K&R
  50. first edition pp 159ff, contains about 7 1/2 pages of (poorly) commented
  51. C code -- and about 10 pages of detailed prose description of what the
  52. code does and how.  Total commentary about 1 1/3 lines of commentary to
  53. 1 line of code.
  54.  
  55.  
  56.     [explanatory commenting....]
  57.    can be a lifesaver for some poor person trying to maintain the
  58.    code at a later time. The fact is that the second comment is
  59.    MUCH larger and could even "hide the code", but there is no
  60.    way that I will stop putting such comments in my code. I care
  61.    too much for those who will follow me.
  62.  
  63. Long and long ago -- so long ago that there is some debate about whether
  64. the managers were cold or warm blooded -- I had my first professional
  65. programming job, in RPG II.  Not known as a clear language, but I was
  66. (*cough*) quite good at it.  I wrote a couple of really nifty modules
  67. that worked wonderfully, in a payroll system.  Now, payroll systems are
  68. notorious for changing a lot, because the Gvt can't seem to settle on
  69. the rules.  About six months after I wrote these nifty modules, I had to
  70. change them.  I didn't have *any* idea what they did any longer.  I
  71. pretty well had to throw them out and rewrite.  From then on, I
  72. commented heavily.
  73. --
  74.         Charles R. Martin/(Charlie)/martinc@cs.unc.edu
  75.      Dept. of Computer Science/CB #3175 UNC-CH/Chapel Hill, NC 27599-3175
  76.         3611 University Dr #13M/Durham, NC 27707/(919) 419 1754
  77.      "Oh God, please help me be civil in tongue, pure in thought, and able
  78.       to resist the temptation to laugh uncontrollably.  Amen." -- Rob T
  79.