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


当前回答

一个文件中5000多行代码中很少的一些注释 事实上,我和那个为自己的编码风格辩护的程序员有过一次争论…… 无可奉告! 没有评论;-)(或者很少) 遗憾的是,这是产品代码。

offset=1;
for (i=0;i<=len;i++)
    {
    if ((i!=0)&&(i<len)) //-3
        {
        switch(mess[i])
            {
            case ETX:
            case ETB:
            case DLE:
                buf[offset]=DLE;
                offset++;
                break;
            }
        }
    buf[offset]=mess[i];
    offset++;
    }

我喜欢这个开关!

for (n=0;n<offset;n++)
{
    Sleep(TR);  //Modif A
    Sleep(T);//
    FWriteFile(hCom,buf+n,1,&dwMot,NULL);
    if (ECHO)
        FReadFile(hCom,tab,1,&dwMot,NULL);
}

不,没有注释解释什么“修改A”是在标题。

if (GetFileSize(hSlotFile,NULL)==3600)   //5*720

720是多少?

其他回答

早在80年代早期,我在汇编器中看到了这个(引用于模糊的记忆):

I don't understand how the following bit works, but it worked in the program I stole it from.
// 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
}
//Woulda
if(x) {}
//Shoulda
else if(y) {}
//Coulda
else {}
//MailBody builders for two outgoing messages
StringBuilder hanz = new StringBuilder();
StringBuilder franz = new StringBuilder();

当我读到这篇文章时,我仍然会笑出声来……

' Oh man I'm pissed. I think I better go home.

哪里喝醉了