Click here to Skip to main content
15,881,938 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)


 
GeneralOut of date comments Pin
jmw24-Jul-10 17:59
jmw24-Jul-10 17:59 
GeneralRe: Out of date comments Pin
Kevin McFarlane25-Jul-10 5:17
Kevin McFarlane25-Jul-10 5:17 
GeneralAll are great about comments Pin
raju melveetilpurayil24-Jul-10 1:37
professionalraju melveetilpurayil24-Jul-10 1:37 
GeneralComments are.. Pin
John Underhill23-Jul-10 2:00
John Underhill23-Jul-10 2:00 
GeneralRe: Comments are.. Pin
LOKImotive5-May-14 12:45
LOKImotive5-May-14 12:45 
GeneralFormatting and Variable Naming Pin
Don Driskell22-Jul-10 9:24
Don Driskell22-Jul-10 9:24 
GeneralDepending on the language comments may not be required Pin
kjmcsd22-Jul-10 8:08
kjmcsd22-Jul-10 8:08 
GeneralRe: Depending on the language comments may not be required Pin
peterchen23-Jul-10 4:02
peterchen23-Jul-10 4:02 
GeneralRe: Depending on the language comments may not be required Pin
tec-goblin23-Jul-10 10:56
tec-goblin23-Jul-10 10:56 
GeneralRe: Depending on the language comments may not be required Pin
peterchen23-Jul-10 11:23
peterchen23-Jul-10 11:23 
GeneralRe: Depending on the language comments may not be required Pin
tec-goblin24-Jul-10 2:53
tec-goblin24-Jul-10 2:53 
GeneralRe: Depending on the language comments may not be required Pin
tec-goblin23-Jul-10 10:57
tec-goblin23-Jul-10 10:57 
GeneralRe: Depending on the language comments may not be required Pin
LOKImotive5-May-14 12:53
LOKImotive5-May-14 12:53 
JokeReal Programmers don't comment their code... Pin
Kevin Drzycimski22-Jul-10 0:08
Kevin Drzycimski22-Jul-10 0:08 
GeneralRe: Real Programmers don't comment their code... Pin
LOKImotive5-May-14 12:57
LOKImotive5-May-14 12:57 
GeneralTrusting someone else sound sense Pin
gstolarov21-Jul-10 15:36
gstolarov21-Jul-10 15:36 
GeneralRe: Trusting doc ... no, but ... Pin
GoodTime Charlie, VA22-Jul-10 7:29
GoodTime Charlie, VA22-Jul-10 7:29 
Like you, after (40+) years as a designer/developer, I've learned the hard way that I can't trust any documentation to actually match the production code.

BUT:

1) When working on a production problem (ie: at 3 am from home or a remote site), I may not have access to my toolsets, read (much less write) access to a production database, or any access to a debug database or system logs, trace files, etc., that are behind a firewall. You also seem to be assuming a robust debug environment exists, has up-to-date data, and/or is not in the format of the next release, etc.

2) I may have designed the application but not developed it; thus, I may not have access to the source code library, etc. I could be looking at only a copy or snippit of code.

3) I may even be in a consulting only role at the moment. It could be I don't have sufficent overall system understanding and/or time to set-up test scenarios/data for debugging a little function within a large complex process, etc.

Simply put: System/code search/debugging/tracing/etc tools may not be an option ... at all or at the moment.

Thus, I look for some documentation to give me a baseline understanding of the code and the mindset of the coder faster (ie: what was this guy thinking when he wrote this junky code ... whoops, I wrote it years ago).

Do I trust (any) documentation? NO!
Do I find it helpful? Yes (generally).
GoodTime Charlie, VA

GeneralRe: Trusting doc ... no, but ... Pin
gstolarov22-Jul-10 8:27
gstolarov22-Jul-10 8:27 
GeneralI comment any code where the purpose (the "why") may be obscure Pin
koolprasad200320-Jul-10 23:16
professionalkoolprasad200320-Jul-10 23:16 
GeneralRe: I comment any code where the purpose (the "why") may be obscure Pin
Tomz_KV21-Jul-10 3:58
Tomz_KV21-Jul-10 3:58 
GeneralRe: I comment any code where the purpose (the "why") may be obscure Pin
Xiangyang Liu 刘向阳21-Jul-10 15:08
Xiangyang Liu 刘向阳21-Jul-10 15:08 
GeneralRe: I comment any code where the purpose (the "why") may be obscure Pin
Tomz_KV22-Jul-10 1:26
Tomz_KV22-Jul-10 1:26 
GeneralA comment on commments Pin
Mike Hankey20-Jul-10 3:33
mveMike Hankey20-Jul-10 3:33 
GeneralRe: A comment on commments Pin
Daniel 'Tak' M.21-Jul-10 3:51
Daniel 'Tak' M.21-Jul-10 3:51 
GeneralRe: A comment on commments Pin
Mike Hankey21-Jul-10 5:06
mveMike Hankey21-Jul-10 5:06 

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.