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


当前回答

我们的DBA在第三方编写的3000行存储过程中发现了这一点。

/* IF DOLPHINS ARE SO SMART, HOW COME THEY LIVE IN IGLOOS? */

其他回答

try
{
...
}
catch(Exception ex)
{
//if this happens the world is going to end...
}

现在猜猜发生了什么……

不是在代码中,而是在相关的bug跟踪系统中:

这不可能是我代码中的bug。我非常小心地编码。

#define SHIT_HAPPENED (BASE + 1)   /* generic shit happened */

在drivers/net/sunhme.c (Linux内核)中:

/* Welcome to Sun Microsystems, can I take your order please? */
if(!hp->happy_flags & HFLAG_FENABLE)
        return happy_meal_bb_write(hp, tregs, reg, value);

/* Would you like fries with that? */
hme_write32(hp, &tregs->frame,
            (FRAME_WRITE | (hp->paddr << 23) |
             ((reg & 0xff) << 18) | (value & 0xffff)));
while(!(hme_read32(hp, &tregs->frame) & 0x10000) && --tries)
        udelay(20);

/* Anything else? */
if(!tries)
        printk(KERN_ERR "happy meal: Aieee, transceiver MIF write bolixed\n");

/* Fifty-two cents is your change, have a nice day. */
// 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"; }
    }
}

我好喜欢双关语。