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


当前回答

这是我最喜欢的评论。

/// I intend to do this as shittily as possible because there are many better products that will totally blow this out of the water
/// and we don't have them so whatever

在后面的文件中,我们有更多的乐趣

/// sidestep a bug in WCF (that we can't send types across)
/// or, depending on how you look at, this issue is a Feature

稍后再讲

if( where == null)//be nice

其他回答

// Jay knows what's going on here, but will he remember in a year? Not very likely, this code sucks, but it works so do not change it.

这条评论被贴在一个巨大的“如果”区块上…哦,它操纵一个对象数组的对象数组的对象数组的字符串对象数组,可以是字符串或数字,取决于至少3个因素…(是的,我必须调试这段代码并更改它,我写了注释,但我没有写原始代码)。;)

来自Apache Xalan源代码:

/**
 * As Gregor Samsa awoke one morning from uneasy dreams he found himself
 * transformed in his bed into a gigantic insect. He was lying on his hard,
 * as it were armour plated, back, and if he lifted his head a little he
 * could see his big, brown belly divided into stiff, arched segments, on
 * top of which the bed quilt could hardly keep in position and was about
 * to slide off completely. His numerous legs, which were pitifully thin
 * compared to the rest of his bulk, waved helplessly before his eyes.
 * "What has happened to me?", he thought. It was no dream....
 */
protected static String DEFAULT_TRANSLET_NAME = "GregorSamsa";

进一步阅读The Daily WTF。

一些来自Linux内核的代码:

/* Sun, you just can't beat me, you just can't.  Stop trying,
* give up.  I'm serious, I am going to kick the living shit
* out of you, game over, lights out.
*/

-

/* 2,191 lines of complete and utter shit coming up... */

-

#if 0 /* XXX No fucking way dude... */
<!-- THIS IS THE MAIN CONFIGURATION FILE FOR THE ENTIRE BLOODY DIRECTORY    -->
<!--    WHATEVER YOU DO, DO NOT EDIT THIS FILE WITHOUT TALKING TO ME FIRST  -->
<!--                                I'M SERIOUS                             -->
<!-- (scroll down) -->

我曾经参与过Windows 3.0的源代码。(我赶紧补充一句,作为一名微软员工,不是!)在那里,我遇到了一个文件加载器,它可以多次重新输入,并且有一个讨厌的双关语的例子(只是为了显示作者有多聪明)。

这些乱七八糟的可重入代码是用Intel程序集jmp指令(在C代码中间)执行的,它的标签是“we_are_not_in_kansas_any_more_toto”。