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


当前回答

发现了一个复杂的代码-

//耶稣和这段代码有一个共同点:都是复活的

其他回答

从一个遗留的Perl CGI脚本:

# This is convoluted and evil, sorry.
# let's pretend we are free, for a while

在教室前面发现了这个。接下来是一个(天真的)实现ORM的尝试。我还是不明白他为什么这么写。

在编写MAPPER应用程序时,我们有一些标准,其中之一就是在整个套件中使用的标准变量列表。其中一个“V43”总是用来表示姓氏。所以,想象一下,当我被要求修复一大块MAPPER代码中唯一的注释是:

Here V43 contains the Surname

这个注释位于一个包含接口的单元中,这些接口用于绑定主应用程序和各种第三方驱动程序之间的通信。

//**************************************
// Dear code maintainer:
//
// This source contains COM interfaces, not to be confused with interfaces 
// of any other sort, please do not just willy-nilly add additional methods 
// to these interfaces as they are truely immutable, unlike the interfaces 
// that other software vendors like Microsoft maintain.  IF you need to add 
// new functionality, then go thru the trouble of creating a NEW interface 
// and implement this functionality on only the objects you need.  
//
// While the money is good for fixing all of the problems caused by not 
// following the rules, I would rather work on things which actually have
// an impact on the future of the product rather than curse and yell 
// obsenities at the screen because someone didn't bother to understand the
// true meaning of IMMUTABLE.  
//**************************************
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;
}