|
I comment any code where the purpose (the "why") may be obscure.
I think each code reader should know about the requirement of the development, in short, he/she should aware of 'WHAT'(is the requirement) , but we should comment for 'WHY'(we code this), cause reader should know 'WHY' I code this line.
(But I doubt how many times, we read comment before going through code )
Rating always..... WELCOME
The only reason people get lost in thought is because it's unfamiliar territory.
|
|
|
|
|
Code is what computers understand and comment is what human can understand. Requirement and coding are some thing different. We can not identify code on the basis of requirement. Comment is meant to quickly explain your code [And to reduce 15mins into 15secs.. ]
"When you don't know what you're doing it's best to do it quickly"- SoMad
|
|
|
|
|
The problem I have with commenting the "what" is that when making changes, you should also update the comments. If that fails to happen for whatever reason, the "what" comment is no longer explains the actual code. You're only going to find out when reviewing both the code and comment.
|
|
|
|
|
Rohan Leuva wrote: Code is what computers understand and comment is what human can understand
*Machine* code is what computers understand. High level programming languages are designed for people.
|
|
|
|