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


当前回答

// haack, phil haack

and:

/* hack, hack, hack, hack, hack hack, hack, hack
 * hackity hack, oh wonderful hacks
 * wonderful hacks, oh wonderful hack, hack, hack
 * hack hack hack... and spam 
 */

编辑:刚刚在我的一些代码中发现了这个(项目希望保持匿名):

// yikes, we need to:
/*
 *       o
 *      -|-     < US CROSSING PLATFORM
 *       |\ 
 ************************************************
 *       |          ^ PLATFORM           |
 *       |                           T   |
 *       |                      TROLL^   |
 */
// right now:
/*
 *   o ./_  | 
 *  -|-[]\  |  (_'_) () (\) | ) \|/ (S) < WALL
 *   |\     |    ^ FRIENDLY MESSAGE FROM YOUR FRIENDS AT MICROSOFT
 *  ***********************************************
 *        | ^PLATFORM                       |
 *      ^ SPRAY CAN (IN HAND)
 */
public static class DefaultFonts
{
    public static string SansSerifPath
    {
        get { return @"C:\Windows\Fonts\arial.ttf"; }
    }
    public static string SerifPath
    {
        get { return @"C:\Windows\Fonts\times.ttf"; }
    }
    public static string MonospacePath
    {
        get { return @"C:\Windows\Fonts\courier.ttf"; }
    }
}

我好喜欢双关语。

其他回答

//说明:!!待办事项

大约10年前,我从事图像处理工作,通过扫描显微镜视频帧来检测细胞运动。我当时在做一个特别复杂的工作,决定和朋友出去喝一杯。当我回到家时,我工作了一会儿,但没有太多,因为我喝醉了。第二天早上,我发现了一个10行完全混乱的函数,带有以下注释(显然是我自己写的):

/* Ah ah ah! You'll never understand why this one works. */

最奇怪的是,它竟然起作用了。

我只是在一个非常简单的大学课程测试c++程序中碰到了这个。

我在评论一个类。

在析构函数中…

// Choose! Choose the form of the Destructor!
// The choice is made! The Traveler has come!
// sometimes I believe compiler ignores all my comments

刚从大学毕业的我渴望亲自动手。我的第一个任务是……“为我注释此代码”。

傻瓜。

过了一段时间我就厌倦了……

// this function doesn't actually calculated the profit, like it says --it really signals the mothership orbiting saturn that the planet is ripe for takeover

[later]

// I don't think anyone is going to read this

[various permutations on that last one]