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


当前回答

/*
This isn't the right way to deal with this, but today is my last day, Ron
just spilled coffee on my desk, and I'm hungry, so this will have to do...
*/

return 12; // 12 is my lucky number

其他回答

写得很好的Lisp是最容易阅读的语言之一,我喜欢它。但是写得不好的Lisp可能是比糟糕的Java更糟糕的噩梦,等等。

在这里,我们需要创建一个“组文件”,如果一个原始文件有3个变体,后缀为a, b和c。我一直试图追踪一个奇怪的错误,我们得到了不必要的组文件……

  (let ((varianta (format nil "~aa" problem))
        (variantb (format nil "~ab" problem))
        (variantc (format nil "~ac" problem)))
    ;;if the A and B variants exist, create a group file
    ;;(why not just check for a? I don't know, this just feels right)
    (when (and (probe-file varianta)
               (probe-file variantb))
      ...)))

Bug: 1, Gut: 0。

显然,写这篇文章的人没有想到,也许检查所有三种变体是一个好主意。当然,这是我在最初编写这段代码十年之后(它比第一个SVN日志更早)最终追踪到的错误。

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

// HERE

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

[onload_1;block=begin;when 1=0]

Some of the techinques in this template are rather obscure, just trust me, they need to be there.
OTOH a better sollution would be to create a few seperate templates and pick one in the php-script...

[onload_1;block=end]
// drunk, fix later

真希望我是在开玩笑。根据编写代码的开发人员的了解,我认为他是认真的。

/*
 * You may think you know what the following code does.
 * But you dont. Trust me.
 * Fiddle with it, and youll spend many a sleepless
 * night cursing the moment you thought youd be clever
 * enough to "optimize" the code below.
 * Now close this file and go play with something else.
 */