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


当前回答

// 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
}

其他回答

.class {border:1px solid gold;} /*我可怜这个傻瓜*/

stop(); // Hammertime!

我尤其对此感到内疚,在我的大多数项目中嵌入了非建设性的注释、代码诗歌和小笑话(尽管我通常有足够的理智在发布代码之前删除任何直接冒犯的内容)。这里有一个我特别喜欢的,放置在一个设计很差的“上帝物体”下面:

/**
* For the brave souls who get this far: You are the chosen ones,
* the valiant knights of programming who toil away, without rest,
* fixing our most awful code. To you, true saviors, kings of men,
* I say this: never gonna give you up, never gonna let you down,
* never gonna run around and desert you. Never gonna make you cry,
* never gonna say goodbye. Never gonna tell a lie and hurt you.
*/

我很抱歉! !我就是忍不住.....!

还有一个,我得承认我还没有真正把它放出来,尽管我很想在我的一个不那么直观的课上这么做:

// 
// Dear maintainer:
// 
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
// 
// total_hours_wasted_here = 42
// 

从Python / ceval.c:

/* This is gonna seem *real weird*, but if you put some other code between
   PyEval_EvalFrame() and PyEval_EvalCodeEx() you will need to adjust
   the test in the if statements in Misc/gdbinit (pystack and pystackv). */

我一直很喜欢Paul DiLascia在他的文件头中写的:

// If this code works, it was written by Paul DiLascia. If not, I don't know
// who wrote it