Where Do We Write Code Comment ?
Code comment takes extra space in the codebase. Where is the best location to write code comment ?
Again, code comment should explain why, not how. So, it should be written before the code being commented. It should also be written right then and there. While the reason and logic is still fresh.
Another location to write code comment is at the top of the file to explain coding standards used and extra information about the file. Especially in library files.
Coding standards include what notation the function naming follows, also variable naming. Extra information may contain the library objective, assumptions being made and other useful information.
Also remember to keep the code comment brief and to the point, because comment is extra information inside the code. People tend to ignore long comments.
Got any good tips on where to write code comment ? Please share in the comment section below.