4 ms·
Personally, I like Linus's take on comments: "Comments are good, but there is also a danger of over-commenting. NEVER try to explain HOW your code works in a
by amouat 13y ago
Personally, I like Linus's take on comments:
"Comments are good, but there is also a danger of over-commenting. NEVER try to explain HOW your code works in a comment: it's much better to write the code so that the _working_ is obvious, and it's a waste of time to explain badly written code.
Generally, you want your comments to tell WHAT your code does, not HOW. Also, try to avoid putting comments inside a function body: if the function is so complex that you need to separately comment parts of it, you should probably go back to chapter 6 for a while. You can make small comments to note or warn about something particularly clever (or ugly), but try to avoid excess. Instead, put the comments at the head of the function, telling people what it does, and possibly WHY it does it."
https://www.kernel.org/doc/Documentation/CodingStyle https://www.kernel.org/doc/Documentation/CodingStyle (Chapter 8)
- amouat 13y agoHmm, maybe I'm just assuming Linus Torvalds wrote that - it could be another kernel dev.