Hacker News new | ask | show | jobs
by ekidd 5661 days ago
I 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: 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.

3 comments

Exactly. Code is for expressing how things are done.* Comments are for expressing why.

* Or if you're not into the whole imperative languages bit, what things are done.

Totally OT: How are you managing to use an asterisk as a footnote indicator and not ending up with the two asterisks invisible and the text in between in italic? I've seen this before and I've tried to replicate it and I can't do it. :-/
An asterisk followed by whitespace doesn't begin italics, so you get * word * rather than word.
Oh. Thank you!
That says what I wanted in less words. I like it. You probably have good comments.
I think this implies that .NET people love them.

http://submain.com/products/ghostdoc.aspx

Write a function like "getFoo" and it generates that as the description. Similar situation example: http://www.youtube.com/watch?v=yPaNRaub8N4#at=40

I believe thats commenting on what your intentions are behind something unclear (or making something that looks wrong look right because of xyz) vs commenting on something that could easily be solved by better naming/conventions.