+ 4

Comments

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

6th Aug 2018, 4:13 AM
vince
3 Réponses
+ 4
Comments are pieces of text ignored by the compiler/interpreter. By conventional coding practises, the comment should explain the code following.
6th Aug 2018, 6:23 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 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.
6th Aug 2018, 6:06 AM
Don
Don - avatar
+ 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.
30th Jul 2020, 10:51 AM
NAKUL DUBEY
NAKUL DUBEY - avatar