你遇到过的源代码中最好的注释是什么?


当前回答

{
This is a gathering place for all unit tests.
Create a TUnitTestWrapper, then call "RunAllUnitTests".

This class will create an instance of each thing to be tested, and call each of
their unit tests.

It does not really do any testing on it's own; it just gives a common place from
which to call everyone else's tests.

This way, one day, we can automate our testing with each build. [Cue laughter]
}

其他回答

# absolutely foul heuristic code.
# ..it's dirty, but you want it.

and:

# VERY USEFUL DEBUGGING AID, for when the above all goes pearshaped:
/* Emits a 7-Hz tone for 10 seconds.
  True story: 7 Hz is the resonant frequency of a
  chicken's skull cavity. This was determined
  empirically in Australia, where a new factory
  generating 7-Hz tones was located too close to a
  chicken ranch: When the factory started up, all the
  chickens died.
  Your PC may not be able to emit a 7-Hz tone. */

main()
{
    sound(7);
    delay(10000);
    nosound();
}

(Turbo C 2.0版本参考指南中的声音功能)

不是一个评论,而是一个goto标签

ICantBelieveImUsingAGoto:

I don't have the code to share, but imagine this scenario. About a month or two after our Linux Sys Admin left for greener pastures, I had the pleasure of opening a shell script he'd written. I can't recall why I needed to edit it, but that's not what matters. What's important is that the script was about 40 lines long. I scrolled past the commenting (of which there were 37 lines) to reach the actual working code (3 lines). The code was great, but I was curious - why 37 lines of commenting? So, I scrolled to the top and proceeded to read. To my surprise, the commenting was a rap about what the three lines of code did and how to change it. The best part - it was a partial rip off of Nothing But A G Thing by Dr. Dre and Snoop D O DOUBLE G. Thanks Brian!

很久以前,我遇到了一些连接脚本,虽然我不记得语法,但我记得注释,因为我是平克·弗洛伊德的粉丝。

//Attempt Handshake: Hello? This is London calling. Are we reaching you?


//Handshake Failed: I don't understand...he just hung up.