Click here to Skip to main content
15,921,548 members

Survey Results

What's more important - easily understandable code or good comments?   [Edit]

Survey period: 1 Sep 2003 to 7 Sep 2003

You would hope to get both, but given a choice, which would you take?

OptionVotes% 
Easily understandable code69066.60
Good comments34633.40



 
GeneralEasy understandable code really exists? Pin
Masaaki Onishi6-Sep-03 17:34
Masaaki Onishi6-Sep-03 17:34 
GeneralComments? Pin
Tim Smith6-Sep-03 7:14
Tim Smith6-Sep-03 7:14 
GeneralRe: Comments? Pin
Bugs Bunny6-Sep-03 10:20
Bugs Bunny6-Sep-03 10:20 
GeneralComment should be useful Pin
Anonymous5-Sep-03 20:53
Anonymous5-Sep-03 20:53 
GeneralRe: Comment should be useful Pin
Jörgen Sigvardsson5-Sep-03 21:30
Jörgen Sigvardsson5-Sep-03 21:30 
GeneralFunction headers Pin
praiseGod7775-Sep-03 7:14
praiseGod7775-Sep-03 7:14 
I have found that it is absolutely invaluable to have a function header at the top of each function that supplies the following basic concepts:

what's the purpose of the function?
what are the individual expected inputs (if any)?
what does the return value mean (if any)?
what assumptions/constraints apply to the input (if any)?

This to me is more important than legible code, and here's why: If you're working on a project that lasts longer than a month then inevitably, you will come to a point where you need an object to do something. You have the concept of what you want it to do in your mind, but you're not sure if it already does it or not. At this point, the last thing I want to do is go back and read code to try to figure out how closely a given function matches my need. I found that being able to browse through function headers increased my efficiency dramatically. Most of the time, I have a vague idea that I coded something like that 6 months ago, but I don't remember what it was called or how exactly I should call it. Browsing these function headers allowed me to very quickly find a function (or a group of functions) that matches the exact description of what I need and will do the job. At this point, I no longer care what the code looks like (assuming that it's working). I just want to be able to call a function that does what I need.

Now, I personally prefer nice, neat, "self-documenting" code within these functions, but suppose it isn't. This isn't really a problem to me, as long as the function does exactly what it says it will do. If it doesn't, and the code is ugly, then I still prefer the function header, because the header gives me an exact picture of what the code should be doing. This way I can fix the ugly, non-working code, without regard to how it's being called and from where. Just make it work as the description promises.

I know that this system has its flaws, but I just headed up building a large application and I was extremely strict on myself and my fellow coders with regards to the use of function headers, and everyone on the project was in agreement that it paid off big-time in the long run, even those who were originally against the idea.

Chris Ellis
GeneralEasy code for the compiler Pin
Dirk Vandenheuvel5-Sep-03 2:23
Dirk Vandenheuvel5-Sep-03 2:23 
GeneralRe: Easy code for the compiler Pin
Anonymous5-Sep-03 8:26
Anonymous5-Sep-03 8:26 
GeneralRe: Easy code for the compiler Pin
Renault the Duck5-Sep-03 17:20
Renault the Duck5-Sep-03 17:20 
GeneralRe: Easy code for the compiler Pin
Anonymous8-Sep-03 7:53
Anonymous8-Sep-03 7:53 
GeneralRe: Easy code for the compiler Pin
Oleksandr Kucherenko5-Sep-03 22:04
Oleksandr Kucherenko5-Sep-03 22:04 
GeneralWhat would you prefer? A straight road or a maze and a map? Pin
G. Raven4-Sep-03 5:49
G. Raven4-Sep-03 5:49 
GeneralRe: What would you prefer? A straight road or a maze and a map? Pin
Paul Oss4-Sep-03 11:54
Paul Oss4-Sep-03 11:54 
GeneralComments, Margins, and Readability Pin
Marc Clifton4-Sep-03 3:08
mvaMarc Clifton4-Sep-03 3:08 
GeneralRe: Comments, Margins, and Readability Pin
Michael P Butler4-Sep-03 5:23
Michael P Butler4-Sep-03 5:23 
GeneralRe: Comments, Margins, and Readability Pin
Marc Clifton4-Sep-03 5:27
mvaMarc Clifton4-Sep-03 5:27 
GeneralRe: Comments, Margins, and Readability Pin
Michael P Butler4-Sep-03 5:49
Michael P Butler4-Sep-03 5:49 
GeneralRe: Comments, Margins, and Readability Pin
Gary R. Wheeler4-Sep-03 7:01
Gary R. Wheeler4-Sep-03 7:01 
GeneralRe: Comments, Margins, and Readability Pin
Anonymous4-Sep-03 10:57
Anonymous4-Sep-03 10:57 
GeneralRe: Comments, Margins, and Readability Pin
cK14-Sep-03 19:00
cK14-Sep-03 19:00 
GeneralRe: Comments, Margins, and Readability Pin
Stephen Quattlebaum5-Sep-03 7:20
Stephen Quattlebaum5-Sep-03 7:20 
GeneralRe: Comments, Margins, and Readability Pin
Jörgen Sigvardsson5-Sep-03 21:30
Jörgen Sigvardsson5-Sep-03 21:30 
GeneralRe: Comments, Margins, and Readability Pin
Festus Redelinghuys7-Sep-03 13:47
Festus Redelinghuys7-Sep-03 13:47 
GeneralRe: Comments, Margins, and Readability Pin
Chris Maunder4-Sep-03 8:19
cofounderChris Maunder4-Sep-03 8:19 
GeneralRe: Comments, Margins, and Readability Pin
Marc Clifton4-Sep-03 8:24
mvaMarc Clifton4-Sep-03 8:24 

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.