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


当前回答

//marco 2007.1.23
//I didn't do it

其他回答

我们有一个小组项目,使用最小-最大树创建一个Connect 4 AI。在我们的move-scoring函数中,我们让它为棋盘计算分数,在这段代码之上有这样的注释:

// This is kind of almost useless

但还有更好的。我们的导师给了我们一些他制作的粗糙AI的示例代码,并留下了很好的评论:

// We also add/subtract some points based on what's going on, on the bottom
// row. (I think this is retarded, but apparently when I coded this up 
// back in 1999 I didn't.)

这个我在Python 2.5的“twisted”包中找到的(文件是tcp.py在第371行)

# Limit length of buffer to try to send, because some OSes are too
# stupid to do so themselves (ahem windows)
return self.socket.send(buffer(data, 0, self.SEND_LIMIT))
/*
 * You may think you know what the following code does.
 * But you dont. Trust me.
 * Fiddle with it, and youll spend many a sleepless
 * night cursing the moment you thought youd be clever
 * enough to "optimize" the code below.
 * Now close this file and go play with something else.
 */ 

这是我最喜欢的评论。

/// 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
//Abandon all hope ye who enter beyond this point