Re: Commenting in Java
- From: "Chris Uppal" <chris.uppal@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 30 Aug 2005 08:55:53 +0100
Eric Sosman wrote:
> My favorite comment of all time was found by a colleague
> debugging someone else's C code:
>
> #define HASHSIZE 51 /* a small prime */
;-)
But....
Did the software depend in any way of the prime-ness of HASHSIZE ? If so, was
that obvious from the code alone (and not via an additional step: "Ah I
recognise this as <such-and-such> algorithm, and I happen to know that only
works well with primes") ? If not, then how would you have known that the
author had made a mistake ?
I can tell the story of a similar mistake that I once made, that (had it not
been caught by an eagle-eyed college -- who /read/ the comments and compared
them with the code) might have had Very Serious Consequences for the company I
worked for.
Redundancy is good. The /reason/ it's good is that errors can be detected, and
ambiguities resolved. In
the case of comments, that means that the possibility of divergence between
code and comment is (one of the many) /advantages/ of commenting, not a
disadvantage.
-- chris
.
- Follow-Ups:
- Re: Commenting in Java
- From: Mike Schilling
- Re: Commenting in Java
- From: Andrea Desole
- Re: Commenting in Java
- References:
- Commenting in Java
- From: js_dev
- Re: Commenting in Java
- From: Mike Schilling
- Re: Commenting in Java
- From: Roedy Green
- Re: Commenting in Java
- From: Eric Sosman
- Commenting in Java
- Prev by Date: Re: simple (?) question about having ";" in the password
- Next by Date: Re: Commenting in Java
- Previous by thread: Re: Commenting in Java
- Next by thread: Re: Commenting in Java
- Index(es):
Relevant Pages
|