home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.software-eng
- Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.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 23:24:22 GMT
- Message-ID: <1992Dec15.232422.8142@cbnewsm.cb.att.com>
- Summary: Yes, _especially_ comment what isn't there.
- References: <1992Dec12.122453.8582@seq.uncwil.edu> <KANZE.92Dec15181119@slsvdnt.us-es.sel.de>
- Lines: 33
-
- In article <KANZE.92Dec15181119@slsvdnt.us-es.sel.de>,
- kanze@us-es.sel.de (James Kanze) writes:
- [ ... ]
- > Again, if you leave out a test for some specific condition because you
- > are convinced that that condition can never occur, some comment as to
- > *why* you are convinced is in order.
- >
- > And any time you use something other than the obvious solution, then
- > some comment as to why it wasn't used is in order. Note that in this
- > case, you're actually commenting the code that *wasn't* written.
-
- These are _very_ important points. They also illustrate the futility
- of any fixed comments:code ratio. "What is the appropriate ratio of
- comments to code that isn't there?"
-
- Yet these are the scariest ones:
-
- /* no test for overflow here; the msg format only has 19 chars */
-
- And then somebody changes the message format. With the comment, you'll
- probably find the error in a reasonable amount of time. Indeed, having
- seen the comment while looking for something else, you are likely to
- remember that there's _something_ you've got to change if the message
- format ever changes, and you've got a decent chance of locating it before
- it becomes an error.
-
- Without a comment like that, lots of luck...
-
- (Of course, you may note that my example comment is a one-liner. :-)
-
- -- Speaking strictly for myself,
- -- Lee Derbenwick, AT&T Bell Laboratories, Holmdel, NJ
- -- lfd@cbnewsm.ATT.COM or <wherever>!att!cbnewsm!lfd
-