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


当前回答

Linux的评论

这里有很多不错的……

这些都是linux中的注释

http://lwn.net/1998/1015/a/f-word.html

我的最爱:

./arch/sparc/kernel/ptrace.c
/* Fuck me gently with a chainsaw... */

./drivers/scsi/qlogicpti.h
/* Am I fucking pedantic or what? */

其他回答

这是我曾经必须支持的实际代码。在努力理解AstaSaysGooGoo和AstaSaysGaaGaa(在那里有更多的astaTempVars被声明和使用)的逻辑之后,我准备放弃。我终于抬头看到了“@author”的评论,整件事开始有意义了。

/*

* @author Andrew Asta
*/
public class AstaClass{

    private String astaVar1;    
    private String astaVar2;    
    private String astaVar3;    
    private String astaVar4;    
    private String astaVar5;    
    private String astaVar6;    
    private String astaVar7;    
    private String astaVar8;    
    private String astaVar9;    
    private String astaVar10;   

    public void AstaSaysGetData(){
        //JDBC statement to populate astavars 1 through 10
        //...
        String astaSqlStatment = "Select astaCol1, astaCol2, astaCol3... From AstaTable Where...";
        //..
        //...
    }

    //Perform data manipulation on astavars...
    public void AstaSaysGaaGaa(){
          [removed for sake of brevity]
    }


    //Perform more data manipulation on astavars...
    public void AstaSaysGooGoO(){
        [removed for sake of brevity]
    }

    public void AstaSaysPersist(){      
        //JDBC statement to save astavars to DB 
        String astaSqlStatment = "Update AstaTable set astaCol1 = @astaVar1
                                                  , set astaCol2 = @astaVar2
                                                  , set astaCol3 = astaCol3... 
                                                  Where...";
    }
}

另外,我更改了实际作者的真实姓名,以避免我陷入任何纠纷等等…

// This is a walkaround for bug #7812

是我们的一个中国程序员写的,他的第一语言不是英语。

我真的很喜欢这个。我碰巧认为“walkaround”几乎比“workaround”更好。

// This procedure is really good for your dorsolateral prefrontal cortex.

你们中有些人,由于某种特殊的原因,不知道DPC,当你深入学习新东西时,你大脑的这一部分会亮起来。

// long live COM'n'Roll
public enum StatusCode
{
        //success codes
        S_OK                                            = 1,
        S_NONE                                          = 2,
        S_SQL_OPERATIONS_LISTS_EMPTY                    = 3,

        //error codes
        E_NO_MATCHING_END_FOUND                         = -1,
        E_SEQUENCE_NUMBER_NOT_FOUND_AT_BEGINNING        = -2,
        E_SEQUENCE_NUMBER_NOT_FOUND_AT_END              = -3,
        E_FORWARD_AND_BACKWARD_OPS_COUNT_DO_NOT_MATCH   = -4,
        E_FORWARD_AND_BACKWARD_IDS_DO_NOT_MATCH         = -5,
        E_IDS_DO_NOT_MATCH                              = -6
}
options.BatchSize = 300; //Madness? THIS IS SPARTA!