home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!uwm.edu!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!tgl
- From: tgl+@cs.cmu.edu (Tom Lane)
- Newsgroups: comp.software-eng
- Subject: Re: Comments:Code (what is the standard guideline?)
- Summary: quantity != quality
- Message-ID: <By6I01.1wF.2@cs.cmu.edu>
- Date: 23 Nov 92 17:02:23 GMT
- Article-I.D.: cs.By6I01.1wF.2
- References: <1992Nov23.152046.5614@brtph560.bnr.ca>
- Sender: news@cs.cmu.edu (Usenet News System)
- Organization: School of Computer Science, Carnegie Mellon
- Lines: 38
- Nntp-Posting-Host: g.gp.cs.cmu.edu
-
- markham@brtph678.bnr.ca (Andrew Markham P205) writes:
- > Some friends wanted to settle a dispute on the comments-to-code
- > ratio that is generally suggested in software engineering circles.
- > Two of us believe a 60:40 comment-to-code breakdown, but the other
- > thinks that is simply too many comments.
-
- IMHO the mere ratio of code to comment characters is uninteresting,
- and any attempt to standardize a ratio is bureaucratic mindlessness.
- The only useful measure of the value of comments is how much information
- they convey that isn't obvious from the code, and this is UNRELATED to
- volume.
-
- Let me give you two examples at opposite extremes. A sorting routine
- might well be considered fully commented with the single line
- /* See Knuth's Art of Computer Programming, vol 3, pp 114-117 */
- if it is a direct implementation of Knuth's exposition of Quicksort.
- There is very little you would want to know that you wouldn't find
- in Knuth's book.
-
- On the other hand, I have seen FAR too much assembly code in the style of
- ...
- add #1,d3 ; add 1 to i
- ...
- where the comments are voluminous but convey hardly any new information.
- (To say nothing of the possibility that the comments are actually in error.)
-
- I also believe that assembly coding usually requires a greater density of
- comments than do high-level languages; for instance, you often use comments
- to mark constructs like loops, if-then-else, and so on, which require no
- comments in HLLs. This suggests that any comment-to-code ratio is
- language-specific.
-
- In short, the interesting question is not the volume of comments, it's
- the quality of the comments. I'm not aware of any simple way of measuring
- the quality; I would say that almost by definition, there is no mechanical
- way of measuring it.
-
- regards, tom lane
-