Quote:Original post by Bregma
Quote:Original post by RyanZec
I don't know why but alot of the stuff in the K&R coding standards seem wierd to be and wanted to get your guys opinions. I will just go through each section that i disagree which.
vi not emacs
cpio not tar
Atari not Amiga
Beta not VHS
Sheesh, kids today. Gettin' so's it's too easy to start a religious war.
I've never even *heard* of cpio, so I guess you're showing your age ;)
Quote:Teh OP
I really don't think naming a variables shorter if it is not used as much is really a good idea.
Try framing it the other way. Wouldn't you want to name a variable *longer* if it's used *more*? Or more precisely, has a wider scope? After all, bigger scopes = more symbols potentially hanging around to conflict, so you want longer names to reduce the chance of conflict. Also to *emphasize* them; things in a wider scope represent values that need to be *remembered* for some reason; and that typically means they're more *important*. So of course they should have a longer name - an honourary title.
"nelems" is horrible, though. "element_count" reads much more cleanly. Just "count" is a way to shorten that (especially if it's clear what's being counted). IMO, don't use "number_of" (or numberOf or however you want to spell it); "count" conveys the same information more easily.
Quote:
For me, my way just seems alot clearer and cleaner.
Many will disagree. What "seems" to be is what you should go with for your own stuff;
de gustibus non disputandum est. If you're given a coding standard, do try to follow it.
Quote:
I have see some if statements that written in the K&R style, I just don't know where any if statement ends just by looking at the code but my way I can clearly see it.
How do you "see" it? By lining up the { with a } in the same column, right? Users of K&R style "see" it by lining up the 'if' keyword with a } in the same column. Same thing, really.
I personally pack things in even closer than K&R (i.e. I "cuddle" elses), because it "looks right" to *me*. Again, de gustibus non disputandum est.
Quote:
Another thing is the space between the statement and the parameters like if () seem like a waste of a space to me, it do not do anything good for the reading of the code.
This sounds inconsistent. A space after a keyword is "wasted space", but a whole separate line for a { character is "useful"?
(I *do* feel fairly strongly about this one. The reason for putting spaces after if/for/while/switch is to distinguish them visually from function calls. I don't particularly like having to rely on syntax colouring to tell that at a glance.)