Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



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

Saliva causes cancer, but only if swallowed in small amounts over a long period of time. -- George Carlin

Working...