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


当前回答

我们有一个小组项目,使用最小-最大树创建一个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.)

其他回答

// Empty constructor to satisfy the stupid compiler
 Public ServletHandlerClass () { } 

我最喜欢的评论是我的一个同性恋朋友说的。他喜欢用VB标记他所有的TODO注释。净,

'TODO: Matt Damon

有时会提供额外的信息,但通常不是这样。

public int hashCode() {
//sucks, but what're you gonna do

/*
int hash = 7;
for (int i = 0; i < array.length; i++)
    hash = hash * 31 * (null == array[i] ? 0 : array[i].hashCode());
return hash;
*/

return 0;
}
# There is a bug in the next line.  $searchParameters != {} will always return true, because {} is creating
# a new hash reference on the fly, and the inequality operater is comparing the memory location of it
# to the memory location of $searchParameters, and they will always be different. 
# This means that the following code will always get executed as long as $nodes is defined.
# I'm leaving it there because it has always been there, and although I'm sure it was originally meant to
# mean %$searchParameters (essentially "is this hash not empty"), I'm afraid to change it.
if ( $nodes && $searchParameters != {} )
{
// This condition can't happen. Call the police or something.