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


当前回答

有一次,我问一个同事如何用我们的内部框架做一些事情(忘了具体是什么,一些晦涩的技术调用)。 他说“简单,看这里”,然后在他的编辑器中打开一个。java文件,在几页代码中间给我看了这个注释:

// HERE

我刚刚检查了一下,注释仍然在这个文件中:)

其他回答

我经历了一个睡眠不足的编程过程,开始只写引用自《搏击俱乐部》的评论。

多年后,我仍然在浏览代码,发现了一条让我发笑的评论。大多数只是随机的想法。然而,我确实保持我的评论行比率相当好!

// This shouldn't happen. The only way this can happen is if the
// <code>JFileChooser</code> has returned a <code>File</code> that doesn't exist
// on the system. If this happens we can't recover, and there is more than likely
// a rip in the space time continuum that the user is too distracted by to notice
// anything else.

 /**
   * This method leverages collective synergy to drive "outside of the box"
   * thinking and formulate key objectives into a win-win game plan with a
   * quality-driven approach that focuses on empowering key players to drive-up
   * their core competencies and increase expectations with an all-around
   * initiative to drive down the bottom-line. I really wanted to work the word
   * "mandrolic" in there, but that word always makes me want to punch myself in
   * the face.
   */
private void updateFileCountLabel() {
// (c) 2000 Applied Magic, Inc.
// Unauthorized use punishable by torture, mutilation, and vivisection.

啊,我一直很喜欢这个……

我刚刚注意到自己在写这个

// not brilliant solution, but fair enough heh.
/* You are not meant to understand this */ 

目前为止最好的一个:

"This code makes baby Jesus very sad!". 

它像这样引用一个String的初始化:

String blankSpaces="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "+ //100 whitespaces
                   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "+ //200 Whitespaces
                   ...
                   "                                        " //100 whitespaces

你懂的。