Click here to Skip to main content
15,888,351 members

Survey Results

Do you comment your code?   [Edit]

Survey period: 19 Jul 2010 to 26 Jul 2010

Some preach that good code requires no comments, while others preach that (good) comments can be as valuable as the code itself. On which part of the spectrum do you lie?

OptionVotes% 
I add comment headers for all public classes, objects and methods, events, fields etc36244.15
I add comment headers for all non-public classes, objects and methods, as well as non-obvious logic inside these24630.00
I provide comments at the top of files17821.71
I comment any code that may be obscure (the "what") to a reader51162.32
I comment any code where the purpose (the "why") may be obscure54466.34
I comment on expected inputs, outputs and other results17621.46
I comment on exceptions, side effects or error codes20525.00
I comment on structures (loop endings, function endings etc)10713.05
I comment as a last resort when I can't make my code any clearer22227.07
I do not comment code.465.61
Respondents were allowed to choose more than one answer; totals may not add up to 100%

View optional text answers (45 answers)


 
GeneralRe: comments should be required Pin
Enrique Albert23-Jul-10 5:47
Enrique Albert23-Jul-10 5:47 
GeneralRe: comments should be required Pin
hfrmobile26-Jul-10 22:59
hfrmobile26-Jul-10 22:59 
GeneralI think it is an exageration that Pin
Xiangyang Liu 刘向阳20-Jul-10 3:00
Xiangyang Liu 刘向阳20-Jul-10 3:00 
GeneralRe: I think it is an exageration that PinPopular
Member 325325820-Jul-10 3:36
Member 325325820-Jul-10 3:36 
GeneralRe: I think it is an exageration that Pin
Xiangyang Liu 刘向阳20-Jul-10 4:03
Xiangyang Liu 刘向阳20-Jul-10 4:03 
GeneralRe: I think it is an exageration that Pin
destynova20-Jul-10 22:04
destynova20-Jul-10 22:04 
GeneralRe: I think it is an exageration that Pin
Xiangyang Liu 刘向阳21-Jul-10 15:00
Xiangyang Liu 刘向阳21-Jul-10 15:00 
GeneralRe: I think it is an exageration that Pin
destynova22-Jul-10 0:44
destynova22-Jul-10 0:44 
Xiangyang Liu 刘向阳 wrote:
None. I guess my argument does not apply to people using assembly languages, maybe unix shell script and perl as well. Just wondering, how much comments do you have to write for assembly code? Maybe 10k of comments for every 1k of code?


Of course assembly language and naturally obfuscated languages like Perl or APL (and very verbose "high level" languages like ATS and ADA) are extreme examples, but I don't think there is a binary division of "languages that need comments" and "languages that need no comments" - more like a sliding scale of understandability ( Poke tongue | ;-P ) inverse to comment frequency.

Most assembly code I've read seems to have maybe a ratio between 1:1 and 1:5 ratio of comments to code (but the less-commented assembly I read was usually for demos, packers and chipmusic players on the 68000-based Atari ST).
Xiangyang Liu 刘向阳 wrote:
You have to write code to explain what you assembly code does? Sorry, can't help it, I know you meant comment instead of code. Smile | :)

Oops, nice catch Wink | ;)
GeneralRe: I think it is an exageration that Pin
RedSonja21-Jul-10 22:55
RedSonja21-Jul-10 22:55 
GeneralRe: I think it is an exageration that Pin
Xiangyang Liu 刘向阳22-Jul-10 2:31
Xiangyang Liu 刘向阳22-Jul-10 2:31 
GeneralRe: I think it is an exageration that Pin
RedSonja22-Jul-10 3:29
RedSonja22-Jul-10 3:29 
GeneralRe: I think it is an exageration that Pin
GoodTime Charlie, VA22-Jul-10 5:58
GoodTime Charlie, VA22-Jul-10 5:58 
GeneralRe: I think it is an exageration that Pin
peterchen23-Jul-10 12:12
peterchen23-Jul-10 12:12 
GeneralNo comment(s) Pin
RomTibi20-Jul-10 1:14
RomTibi20-Jul-10 1:14 
GeneralRe: No comment(s) Pin
Fernando A. Gomez F.21-Jul-10 8:12
Fernando A. Gomez F.21-Jul-10 8:12 
GeneralRe: No comment(s) Pin
savire21-Jul-10 22:45
savire21-Jul-10 22:45 
GeneralRe: No comment(s) Pin
hfrmobile26-Jul-10 23:02
hfrmobile26-Jul-10 23:02 
GeneralHow vs What Pin
Eksith20-Jul-10 0:37
Eksith20-Jul-10 0:37 
GeneralRe: How vs What Pin
Theraot20-Jul-10 23:39
Theraot20-Jul-10 23:39 
GeneralThis poll and maby more other polls Pin
RomTibi19-Jul-10 23:00
RomTibi19-Jul-10 23:00 
GeneralComment Everything PinPopular
Deus ex Machina19-Jul-10 11:56
Deus ex Machina19-Jul-10 11:56 
GeneralRe: Comment Everything Pin
RedSonja19-Jul-10 21:15
RedSonja19-Jul-10 21:15 
GeneralRe: Comment Everything Pin
Roland7121-Jul-10 15:31
Roland7121-Jul-10 15:31 
GeneralA college TA.... Pin
El Corazon19-Jul-10 6:48
El Corazon19-Jul-10 6:48 
GeneralRe: A college TA.... Pin
Ennis Ray Lynch, Jr.19-Jul-10 7:08
Ennis Ray Lynch, Jr.19-Jul-10 7:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.