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


当前回答

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

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

其他回答

看这个:

'On Error Goto Hell.
// this is really complicated

没有其他评论了

在拉丁语中,从但丁的《神曲》中进入这里的人,请放弃希望。

我告诉学员至少做一些异常处理。这是我在每一个db调用....返回

Catch (Exception e) {
    //eat it
}
//MailBody builders for two outgoing messages
StringBuilder hanz = new StringBuilder();
StringBuilder franz = new StringBuilder();

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