home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.software-eng
- Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!att!cbnewsm!lfd
- From: lfd@cbnewsm.cb.att.com (Lee Derbenwick)
- Subject: Re: C code Layout
- Organization: AT&T
- Date: Tue, 15 Dec 1992 18:04:36 GMT
- Message-ID: <1992Dec15.180436.28384@cbnewsm.cb.att.com>
- References: <1992Dec14.074411@eklektix.com> <KANZE.92Dec15171105@slsvdnt.us-es.sel.de>
- Lines: 39
-
- In article <KANZE.92Dec15171105@slsvdnt.us-es.sel.de>,
- kanze@us-es.sel.de (James Kanze) writes:
- [ in answer to one of my comments on excessively large comments: ]
- > |> One reason that I personally dislike very large comments embedded in
- > |> the code is that they greatly reduce the amount of code within my
- > |> visual field (whether on a screen or on paper) [ ... ]
- >
- > I was surprised that this argument wasn't mentioned earlier in this
- > thread, as it seems quite popular, at least amongst Cambridge
- > graduates, where it seems to be called the band width theory. [ ... ]
- >
- > Of course, this means that you also put several short statements on
- > the same line, code on the same line as the opening brace, etc. And
- > of course, you never, never leave a line blank.
- >
- > This also argues for short variable names. (They increase the chances
- > of getting more than one statement on a line.)
-
- Let's start with the opposite extreme. Should we mandate 1000 lines
- of comments for every line of code? No? Okay, "We've established
- what you are, now I'm trying to establish your price." :-)
-
- Certainly at _some_ point you have too many comments. Similarly, if
- you make the code too dense, it becomes unreadable. The question is,
- where is the appropriate point? The "band width theory" is a useful
- metric, but it is only one of the driving forces. "Chunking" of
- concepts has already been mentioned in this thread as another driving
- force.
-
- Just taking these two into account can lead to some guidelines for
- where large comments should be. A 10-line comment detailing a tricky
- (but not terribly long) loop is likely to interfere seriously with
- "chunking" if it is embedded in the middle of the loop. But the same
- comment, placed before the loop (and set off by blank lines!) will
- convey the information without interfering with the visual cues.
-
- -- Speaking strictly for myself,
- -- Lee Derbenwick, AT&T Bell Laboratories, Holmdel, NJ
- -- lfd@cbnewsm.ATT.COM or <wherever>!att!cbnewsm!lfd
-