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


当前回答

我们的团队,就在今晚,发布了一个新版本的CSS文件,删除了一个文件的注释,该文件的结构是这样的:

@charset "UTF-8";
/* Who knew comments here could COMPLETELY ruin our page in Safari? */
body {
        /* Really important stuff here */
        /* Of course, comment or not, this will all get ignored by Safari because 
           its the first rule after the comments which break everything.
           see http://www.w3.org/International/questions/qa-css-charset for the exact details!
        */
}

有趣的是,在网上你会发现人们的解决方案是输入一个虚假的元素作为字符集语句下面的第一条规则,然后被忽略,照常进行…

发人深省的问题:该把不评论的评论放在哪里?

旁注:我知道这是不需要的,因为头,元规则等。不幸的是,我们需要它作为一个catch all:(

其他回答

事实上,有一天我在一些代码上看到了这个,这些代码是在截止日期很急的时候写的。

//This was clearly written under duress
// Caveat implementor

这是我们在前雇主购买的智能卡产品中发现的唯一一条评论。一群荷兰密码学博士写的嵌入式C语言和汇编程序

// echt halmaal gek - no way!

(它的意思是“真的完全愚蠢”……这对我们也没有帮助)

i++; // increment variable i

在一个著名的商业DOS电子表格应用程序中:

/* This comment was just added in order to check-in a file that was last 
checked in by [Insert Programmer FirstName] "Back-to-the-Future" [Insert 
Programmer LastName]. While testing for year 2000 problems, he accidentally 
checked-in this file while his machine clock was set forward to the year 2000. 
This meant that the source code was always newer than the object file and 
compiled every time the code was built. I'm checking this file in again to 
fix that. */