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


当前回答

首先,在一个大对象的更新的开始:

/*General note to all who tread in the <ObjectName>() code...
 * The SetOriginals() method from the BaseEntity class should be called (and only called) right after the Get() method
 * call as seen above.  Calling the SetOriginals method elsewhere will result in bugs and all kinds of other nasty suprises.
 */

然后在大约200行逻辑之后更新对象:

//Attempt to explain this confusing mess of code:
//First time you save an actual absence this is what happens:
//0. The first save saves to the <TableName> table (among other things). (Fig. A)
//1. The <CalculationMethod> method is called next which inserts to the <OtherTableName> table. 
//(This is the table that keeps track of credits to the case.) (Fig. B)
//2. So then you have to call <UpdateCalculations> to move the <TableName> records to the <ThirdTableName> table. (Fig. C)
//3. Then you go back and run calculations since you have the debits table (<ThirdTableName>) populated. (Fig D.)
//4. Then a final save to save the calculations back to the case. (Fig. E)
//Yeah, I know what you're thinking:  this sucks. 10/01/07 XXX

开发商是对的……这太糟糕了!

其他回答

我发现了这个:

I'm not sure what I did

在编写MAPPER应用程序时,我们有一些标准,其中之一就是在整个套件中使用的标准变量列表。其中一个“V43”总是用来表示姓氏。所以,想象一下,当我被要求修复一大块MAPPER代码中唯一的注释是:

Here V43 contains the Surname

当我在高中上计算机课的时候,我们在一个普通的教室里上课——没有电脑。我们所有的测试都是在纸上完成的,一张纸上有一节课。我们的老师是第一次用c++授课,偶尔会在黑板上切换到Pascal模式。这很尴尬,因为我们中很少有人对学习帕斯卡感兴趣。

对于比课堂作业更大的作业,我们会在家里做,并提交代码和输出打印结果来评分。在提交了一些代码+输出输出后,我们共同意识到老师实际上并没有阅读代码-只是打印输出。为了测试我们的理论,我在代码的第三页放了一条注释——就在一些类声明之间:

// If you are reading this, please place a checkmark here [  ]

当然,我把它拿回来的时候,前面有一个大大的蓝色“a”,没有任何标记。

when :orientation
## Avoid matching gay people with straight people - they hate it, they do, they really do.
query_parameter = "(users.orientation = 'Bi' OR (users.orientation = 'Straight' AND users.gender IN ('#{user.opposite_genders.join('\',\'')}')) OR (users.orientation = 'Gay' AND users.gender IN ('#{user.same_genders.join('\',\'')}')))"

从一个约会网站…

//        .==.        .==.          
//       //`^\\      //^`\\         
//      // ^ ^\(\__/)/^ ^^\\        
//     //^ ^^ ^/6  6\ ^^ ^ \\       
//    //^ ^^ ^/( .. )\^ ^ ^ \\      
//   // ^^ ^/\| v""v |/\^ ^ ^\\     
//  // ^^/\/ /  `~~`  \ \/\^ ^\\    
//  -----------------------------
/// HERE BE DRAGONS

我没有原始文件的权限,因为我已经不在那里工作了,但它和这张照片非常相似。它位于文件的顶部,总是会引起麻烦,我们必须修复,但不允许花时间真正修复。(大学政治)