Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×

Comment Re:Comments are good (Score 1) 660

Comments shall be avoided as much as possible :

No. Bad comments should be avoided. Those are the comments that add nothing to the code.

1) the code shall be simple and the name of variables and methods shall be self explanatory in most cases.

Reasonably naming variables and methods is a given. Most of the time the comments are (or should be) used to explain why a certain function was created and coded that way, rather than putting in plain english what we can tell just by reading the code. The requirements behind your coding can be (and often are) as relevant as the code itself.

2) the more you add comment lines, the less lines of code you can see on your screen.

True, but unless you're coding with chisel and stones, this is really irrelevant. A program is not a novel that requires two pages of comments to explain a few lines of code. Whoever does this is missing the whole point of code commenting.

3) comments introduce a redundancy.

They do not, if they're done properly. As aforementioned, comments are needed to explain reasons that one cannot tell from the code.

Slashdot Top Deals

"Gravitation cannot be held responsible for people falling in love." -- Albert Einstein

Working...