owen@uw-june (Owen Beckley) (04/08/85)
Well, here are the results to my C indentation/commentation survey. As a reminder, here are the catagories that I posted. Block indentation: 1) if (a == b) { 2) if (a == b) { statement1; statement1; statement2; statement2; } } 3) if (a == b) 4) if (a == b) { { statement1; statement1; statement2; statement2; } } 5) if (a == b) 6) other, please specify { statement1; statement2; } "End" comments: a) if (a == b) b) if (a == b) { { statement1; statement1; statement2; statement2; } /* if */ } /* end if */ c) none d) other, please specify e) no vote (I added this after receiving many "no votes") If the persons "other" vote only differed from one of the given choices by the number of indention spaces, I moved it to the appropriate catagory. This would be a user setable option. Indentation Type Totals for Comment type 1 2 3 4 5 6 | V a 15 0 7 4 3 0 29 b 16 5 13 7 5 0 46 Comment Type c 88 21 44 26 1 3 183 d 13 3 8 10 3 3 40 e 8 3 4 4 0 1 20 Totals for Indent type -> 140 32 76 51 12 7 318 <- total votes Summary of replies: Indentation: 1) As you can see, the results are highly in favour of the traditional K&R style. Many people said they liked this one because it saves screen lines. I also think that this is the only one many people have seen, and thus it is the only one that looks right. 2) The people that chose this one usually said something about saving lines and that the brace belongs with the statements rather than the if. 3) This one was chosen mostly for the ease of lining up the matching braces. 4) This one was chosen by most people that hinted that they were Pascal/ Algol/ PL/I programmers. It leaves the left margin fairly clear, is easy to line up the braces with, and puts the braces with the compound statement and not the if. 5) This one was chosen for its readability and reasons like 4. 6) These "others" were quite varied and some were very strange. Comments: a) This was chosen by those who thought the "end" was redundant. b) The people that chose this one thought that it had the most meaning. c) This was chosen by most because they thought that "end" comments just clutter up the code and that commenting the syntax and not the semantics was generally worthless. d) Most who chose the "other" catagory said that they would comment on the meaning of the condition or the compound statement itself rather than the syntax of the if. e) Some people didn't have any preference, and others just don't know how to read directions :-) Many of the people also said that they would only use these comments when the "}" was a long way down the program from the "{" (i.e. the next page/ screen or farther). I would like to thank all who responded and those of you that kept your replies short and concise. And now for some FLAMES! I did not appreciate those of you who sent back my entire article. Don't you think I know what I posted? I really didn't appreciate Jim Cottrell's reply. No, number 1 is not any more "correct" than any of the others are "wrong." The results show that there are many people that don't think it's the only way. Jim also states that there must be 8 spaces in a tab. Who says there has to be a tab stop between each level of indentation. I programmed for 4 years without using them because the machines I used didn't like them and my professors wanted 3 spaces. Also, who says a tab stop has to be 8 spaces; typewriters have been around a lot longer than computer terminals, and on them you can set the stops to anything you want. The fire is under control now. I don't know when I'll have the time to write/modify some mlisp functions, but now I have a good idea what people would like. Thanks again for all of the responses. P.S. Sorry about the assignment operator in the condition. My goof. ----------------------------------------------------------------------------- Gentlemen in white suits: Man of the house: We've come for your liver. - What? You do have a liver donors card, don't you? - Why, yes. Well, we've come for your liver! - Aaaaaaaaaaaaaaah! Owen Beckley |\ University of Washington Computer Science /| \ owen@{uw-june.arpa|washington.arpa} / | \ {ihnp4|decvax|cornell}!uw-beaver!uw-june!owen /__|___\ \______/ Bring Back The Cup -- ----------------------------------------------------------------------------- Gentlemen in white suits: Man of the house: We've come for your liver. - What? Do you have a liver donors card? - Why, yes. Well, we want your liver now! - Aaaaaaaaaaaaaaah! Owen Beckley |\ University of Washington Computer Science /| \ owen@{uw-june.arpa|washington.arpa} / | \ {ihnp4|decvax|cornell}!uw-beaver!uw-june!owen /__|___\ \______/ Bring Back The Cup