My Case Against Code Comments
jakusys.de
My Case Against Code Comments
1–10 of 23 posts
Re: My Case Against Code Comments
#2Re: My Case Against Code Comments
#3The code itself is always the first, best, and final authority on how it works. Comments should add something beyond that, or they should not be there at all. The Thou Shalt Comment mindset is responsible for most bad comments. Ignore it and only comment when it will do the reader a service.
Re: My Case Against Code Comments
#4However, I _love_ seeing the following types of comments:
1. The high-level overview of how things fit together: This class represents a compiled method at the VM level. It does not contain the actual native code. If native code exists, it is handled using class Blah instead.
2. What should work, but doesn't: You'd think the following two lines of commented-out code would work, but they don't, because libfoo 1.7.1 and earlier has a stupid bug, so we need to do things the hard way.
3. The epic warning: Apple's Component Manager API does not work the way you'd naturally assume. First of all, it constructs a single 'instance' of a class before it initializes the class. Second, the memory reclamation system is really weird... and so on, for a page and a half.
Re: My Case Against Code Comments
#5It's nice to see that yet one more person has come to their senses. Not much new in that post, but sometimes that's ok. The code itself is always the first, best, and final authority on how it works. Comments should add something beyond that, or they should not be there at all. The Thou Shalt Comment mindset is responsible for most bad comments. Ignore it and only comment when it will do the reader a service.
Re: My Case Against Code Comments
#6[I don't comment unless it's a TODO or a DONT EVER... ]
Re: My Case Against Code Comments
#7Is the "Error establishing a database connection" on your site illustrative of their mischief at work? [I don't comment unless it's a TODO or a DONT EVER... ]
http://webcache.googleusercontent.com/search?q=cache:-cU7R0Q...
Re: My Case Against Code Comments
#8I think everybody hates comments like "getFoo: Get the value of Foo", and huge blocks of commented-out code. However, I _love_ seeing the following types of comments: 1. The high-level overview of how things fit together: This class represents a compiled method at the VM level. It does not contain the actual native code. If native code exists, it is handled using class Blah instead. 2. What should work, but doesn't:…
* Or if you're not into the whole imperative languages bit, what things are done.
Re: My Case Against Code Comments
#9 /** Class FooBar - The purpose of this class is to do XYZ... */
public class FooBar { ... }
>This is one of my favorite examples. Almost an entire line of comments wastedNot if you use a documentation-builder. They frequently result in simple documentation turning into several lines (@param desc \n @param desc, and the like). /* * does xyz * / does not imply it is documenting that class and only that class. It could easily be meant for two or three classes in the same file, as they could be part of a greater whole.
Re: My Case Against Code Comments
#10It's nice to see that yet one more person has come to their senses. Not much new in that post, but sometimes that's ok. The code itself is always the first, best, and final authority on how it works. Comments should add something beyond that, or they should not be there at all. The Thou Shalt Comment mindset is responsible for most bad comments. Ignore it and only comment when it will do the reader a service.
In theory everything you've said is accurate. In practice it's usually really hard (if not impossible) to know exactly who "the reader" will be in six months. Nothing says "prima dona" to me quite like encountering a few thousand lines of someone else's code that they couldn't even be bothered to document the major functions.