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


当前回答

今天刚加了这个:

// Hardcoded this for time sake ... will make andrew fix later :)

其他回答

// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...

在一堆糟糕的剪切和粘贴源代码的内容管理web应用程序:

// load image 1 - JPEG 240x320
img = f1.getImage();
if (check(img))
{
   load(img, Constants.JPEG_240x320);
}

// load image 2 - JPEG 128x128
img = f2.getImage();
if (check(img))
{
   load(img, Constants.JPEG_128x128);
}

...

// load image 13 - GIF 256x256
img = f13.getImage();
if (check(img))
{
   load(img, Constants.GIF256x256);
}

// loaded all of the f**king images

注:大致翻译自意大利语:-)

在20世纪80年代早期的某个时候,我们在PL/I中为公用事业编写财务建模代码。接到一个客户的电话,说代码在评论之后就爆炸了

/* Honest this works */

这家伙用了我们的标准金融方程花了大约15页的代数把一堆代码组合成一个方程。在三里岛事件后,当公用事业公司不得不以巨大的代价注销他们的核电站时,这个方程失败了,因为FIXED BIN 15(整数)溢出,如果代数没有发生,就不会发生这种溢出。

注意上面代码中的bug;我只是证明了它是正确的,并没有尝试过。

这是唐纳德·克努斯写的。

// Bad Christian, No cookie

这里的Cookie不是指浏览器Cookie