Re: derangement: code review request
From: Tim Rentsch (txr_at_alumnus.caltech.edu)
Date: 10/27/04
- Next message: Flash Gordon: "Re: couple of questions on streams"
- Previous message: Gerry Quinn: "Re: C to Java Byte Code"
- In reply to: Richard Bos: "Re: derangement: code review request"
- Next in thread: Richard Bos: "Re: derangement: code review request"
- Reply: Richard Bos: "Re: derangement: code review request"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Oct 2004 03:55:37 -0700
rlb@hoekstra-uitgeverij.nl (Richard Bos) writes:
> Tim Rentsch <txr@alumnus.caltech.edu> wrote:
>
> > A couple of the names use abbreviations as part of the name (eg,
> > 'fam_size'). I recommend using the whole word, and always avoiding
> > abbreviations.
>
> I disagree. Even for normal abbreviations, not just for acronyms,
> industry-standard abbrevs are probably more legible than the whole word.
>
> I mean, my main program deals with entering data for advertisement. Can
> you imagine how much larger and less legible my code would've been if
> I'd used advertisement_width_in_columns everywhere I know have adv_cols?
How about 'ad_columns'? My unabridged dictionary includes 'ad' as a
word. If 'ad_columns' is still too long for you, 'ad_width' has the
same number of letters as 'adv_cols'.
> > void
>
> Ew, ganoo style.
It's hard to know how to respond to a statement that is clearly
nothing more than name calling. If you have a comment about the usage
rather than just an objection to some people who happen to use it, how
about letting us know what that is?
By the way, I've been writing return-type-on-a-separate-line style
function definitions in C since before the GNU project was formed.
> > generate_random_derangement( unsigned a[], unsigned n ){
> > unsigned i, j, t, r, r_limit;
> >
> > r_limit = RAND_MAX - RAND_MAX % n;
> >
> > for( i = 0; i < n; i++ ) a[i] = i;
>
> Ew ew ew! You just proved that whitespace isn't _always_ good (and
> whitespace on the _inside_ or parens rarely is).
If indeed something has been proved here, a better candidate is that
the spacing style used above is something Richard Bos is unaccustomed
to seeing.
The spacing style exemplified in the 'for' statement above arises
out of several considerations (among others):
1. The multiple spaces make it easier for my eyes to separate
the several control clauses of a 'for', and easier for my
brain to chunkify them.
2. Following a precept of Hoare's: Things that are different
should look different; hence, I don't put spaces inside
parentheses surrounding sub-expressions (at least not
usually), but I do put spaces inside parentheses used in
function calls/definitions, and also inside parentheses
used with control expressions.
3. Control expressions (in 'for', 'if', 'while', etc) are
different in character from other expression uses, and
often more central to understanding how an algorithm
works; using two spaces around control expressions helps
them stand out from the other code around them, which in
my experience aids comprehension.
Aside from your gut reaction, do you have any statement to offer about
why one might prefer an alternative spacing style over a style like
the one shown above? It seems like all you've said is, "In my
opinion, it's bad." Anything more objective to propose?
> How about this more
> moderate version:
>
> for (i = 0; i < n; i++) a[i] = i;
>
> In fact, I'd prefer
>
> for (i=0; i<n; i++) a[i]=i;
>
> But double spaces? Yuck.
I've tried both of the moderate versions. I prefer a style that is a
little more heterogeneous, for the reasons explained above; just as
in writing prose, too much homogeneity can itself make the text less
readable.
I admit the wider spacing looks strange at first and takes some
getting used to. That doesn't have to mean it's the wrong path;
the first time I ate sushi I didn't like it either.
- Next message: Flash Gordon: "Re: couple of questions on streams"
- Previous message: Gerry Quinn: "Re: C to Java Byte Code"
- In reply to: Richard Bos: "Re: derangement: code review request"
- Next in thread: Richard Bos: "Re: derangement: code review request"
- Reply: Richard Bos: "Re: derangement: code review request"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|