Comments | Sololearn: Learn to code for FREE!

+4

Comments

So basically comments are describing what the line of code does but doesnt affect it in a way

8/6/2018 4:13:05 AM

vince

3 Answers

New Answer

+4

Comments are pieces of text ignored by the compiler/interpreter. By conventional coding practises, the comment should explain the code following.

+2

Yes. You are right. But comments shouldn't necessarily explain exactly what the code does that should be self explanatory just by looking at it by the logic and good naming convention. But comments should be utilized to explain "Why it's done like that". Some code is self explanatory take this: // Set x variable to Don string x = "Don"; First terrible naming convention. Secondly, it's pretty obvious what it does. We can essentially solve this with good naming conventions. Change x to name.

+1

Yes, completely right. It's basically for the other coder to understand that what actually is going on in that particular code or segment.