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


当前回答

try {
   doSomething();
} catch(err) {
   // Die quietly
   alert(err);
}

其他回答

I was doing a database in Access, very simple thing - at least it was supposed to be at the start or I would have done it in Delphi. The client wanted to be able to get the customer info out of the database but they would not enter enough information to reliably identify the customer. I told them to use the phone number as the key as each customer (the way they worked, not for everyone) would have a different number. After a few frantic calls from them, (It's not working we can't enter the customer) I discovered that they were too lazy to look up the phone numbers from their old system and were trying to enter all the numbers they did not know as "n/a". In trying to sort this out for them I ended up with a lot of checking loops in the code and had the comment beside one outcome "This should never be reached if they do what they are supposed to do!!!!!!!!!"

他们还曾经问过我:“即使我们输入了错误的地址,我们如何才能找到正确的客户?”而这一切都是为了花生。

// No women, no children... What movie???

在一个名为“Bar”的类中(这是一个不具有描述性名称的UI控件),类头文件:

/// <summary>I pity the "foo".</summary>

Remove()方法:

/// <summary>A "foo" and his money are soon parted.</summary>

更糟糕的是,业务合作伙伴从生成的文档中指出了这一点。更糟糕的是,这些可能是我们从那家伙那里得到的最接近有用文件的东西。

// GK Experimental

(GK是编码器的首字母缩写)

用来表示部分代码,实际上,是实验性的。:)

这是一个很好的标志,当你在调试过程中碰到它时,你可能会在接下来的几个小时里忙着修复黑客。;)

/* Emits a 7-Hz tone for 10 seconds.
  True story: 7 Hz is the resonant frequency of a
  chicken's skull cavity. This was determined
  empirically in Australia, where a new factory
  generating 7-Hz tones was located too close to a
  chicken ranch: When the factory started up, all the
  chickens died.
  Your PC may not be able to emit a 7-Hz tone. */

main()
{
    sound(7);
    delay(10000);
    nosound();
}

(Turbo C 2.0版本参考指南中的声音功能)