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


当前回答

我在我发布的WordPress模板中发布了这个“许可声明”。不管怎样,我觉得这很有趣。

/* The License:
You (from this point on referred to as The You) are hereby 
granted by me (from this point on referred to as The Me) 
license to knock yourself silly with this template. 
By using this template The You implicitly accepts this 
license and pledges solemnly to never claim creative 
ownership of any graphics, code, concepts, eggs, bacon, ideas, 
colors, shapes, hypertext-transfer protocols or other conduits 
of the visual splendor thatis this template. 

The Me, in turn, pledges equally solemnly to be far too 
lazy to ever check up on you, so if you do manage to pull 
some chicks The Me won't have a cow. 
However The Me would be sorely disappointed if The You 
were to try and sell or distribute this work without 
acknowledging The Me. Seriously. The Me will come down on 
The You like a large quantitiy of hard and heavy objects 
that in large quantities may be harmful and possibly even 
lethal to The You; So don't even think about it, The Buster.
*/

其他回答

// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...

我们的团队,就在今晚,发布了一个新版本的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:(

//Abandon all hope ye who enter beyond this point

消毒:

//Forward declarations:

class X {}; // TODO: Remove {}  ! When we get X defined....
//Dear future me. Please forgive me. 
//I can't even begin to express how sorry I am.  

我今天刚发现了这个:

//private instance variable for storing age
public static int age;