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


当前回答

这是我们团队微观管理效果的一个活生生的例子:

// I am not responsible of this code.
// They made me write it, against my will.

... 我们敬爱的技术总监很喜欢把代码和编码指南都硬塞到开发人员的喉咙里(*)。

当然,当项目负责人寻找bug的原因时,发现它在“非最佳代码”中,他就不那么高兴了……

(*)当然,我指的是强大的VB国王……如果你想评估强大的VB国王的全部力量,你可以阅读下面的SO帖子:你被迫遵循的最奇怪的编码标准规则是什么?...

其他回答

private static final Logger lager = new Logger();

从《雷神之锤III》的资料中,我在一些随机的帖子中偶然发现了这一点。该文件的完整源代码可以在这里找到。这是一种非常快速的求平方根倒数的方法。至于最好的评论呢?当然,这是一种常见的方法,但考虑到它附着在直线上,它的神奇之处在于它的伟大之处。

float Q_rsqrt( float number )
{
  long i;
  float x2, y;
  const float threehalfs = 1.5F;

  x2 = number * 0.5F;
  y  = number;
  i  = * ( long * ) &y;  // evil floating point bit level hacking
  i  = 0x5f3759df - ( i >> 1 ); // what the fuck?
  y  = * ( float * ) &i;
  y  = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
  // y  = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

  #ifndef Q3_VM
  #ifdef __linux__
    assert( !isnan(y) ); // bk010122 - FPE?
  #endif
  #endif
  return y;
}
//Abandon all hope ye who enter beyond this point
/* You are not meant to understand this */ 
THIS PROGRAM HAS CODE THAT DOES NOT MEET STANDARDS      

这个评论几乎出现在我们这里的每一个节目中....