+ 4
Comments
So basically comments are describing what the line of code does but doesnt affect it in a way
3 odpowiedzi
+ 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.