+12

Why we use comments in programming?

Is it mandatory to use comments?

4/19/2019 10:30:39 AM

Ajay Bamniya

30 Answers

New Answer

+14

Using Comments in our code is very helpful for the users reading our code... Although it is not compulsory but yet you should insert comments like <!--Table section started --> Or //Table section started It also helps the coder writing the code in knowing where the table section started and where ended ... /* Note : As many Comments in your code may make your code look bad ... */

+11

If you provide your program then comments help them to read your program..

+10

Of course, short comment like "getting names from an array" is nice, but something like "looping an array with class members names and use it to..." is too long.

+10

On the other hand if the methods are short their names tell us a lot.

+9

The usefulness of comments usually occurs to us a few months in. When we look again at codes we wrote ourselves a few weeks ago. And suddenly have trouble understanding how they even work.

+9

In my opinion code should be readable without comments. So use them when the situation requires it.

+8

They are like notes to readers of the code including the writer.

+7

For youself and for future programmers, who maintain your code

+6

Comments are not necessary. They are used to make code more readable.

+6

Bilal Ahmed thank you help me

+6

HonFu thanks

+5

Thank you so much Alexander Sheremet

+5

Barteker thanks

+5

UraL thanks

+5

Sonic thanks

+4

Thank you Mukul

+4

Barteker, but a one-line comment over a 'paragraph' of code, say over ten coherent lines of code that do one thing, can still make a code more readable, even if it's well written.

+4

Luis Ch. Thanks

+4

If you working with team or if you working on something very long or difficult ,"comments help you renumber "

+3

Mr. Anonymous Thank you so much 😃