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


当前回答

不是代码注释,而是SVN在同一个文件上提交注释:

第一次提交(在测试人员返回结果后,再进行数十次提交):

Squashed some IPR mod bugs. The were big and juicy ones, too.

2日提交:

Squashed some more mod bugs. Those are some nasty bugs, them mod bugs...

3rd:

Squashed some more mod bugs. They are like cockroaches: they'll live through a nuclear war.

4th:

Squashed some more John bugs. They too are like cockroaches: they appear anywhere John goes. Wait. That doesn't sound right.

5:

Same John bug. It didn't die, just played 'possum.

是的,我厌倦了"修复bug"

其他回答

生产源代码:

// Remove this if you wanna be fired

回到《Hitchhiker’s Guide》刚问世的时候,我曾经测试过某些内容是否可滚动,以及用户是否尝试着滚动,这是一种限制可变长度的语言。所以:

if (scroll and noScroll) # or tea and no tea

在linux 1.0内核调度器(schedule .c)中:

Dijkstra可能讨厌我。

/*
 *  'schedule()' is the scheduler function. It's a very simple and nice
 * scheduler: it's not perfect, but certainly works for most things.
 * The one thing you might take a look at is the signal-handler code here.
 *
 *   NOTE!!  Task 0 is the 'idle' task, which gets called when no other
 * tasks can run. It can not be killed, and it cannot sleep. The 'state'
 * information in task[0] is never used.
 *
 * The "confuse_gcc" goto is used only to get better assembly code..
 * Dijkstra probably hates me.
 */
asmlinkage void schedule(void)

(…)

我参与的一个大型项目在自动构建中使用了StyleCop和FXCop,并使用规则来防止人们检入带有未注释字段、方法、属性等的代码。

有些人对必须添加“获取或设置全名”之类的注释到自记录属性(如FullName)感到非常恼火,以至于他们不得不努力编写一个宏来绕过这些规则。

宏为方法、属性等插入了XML摘要标记,其中一个单一的不显示Unicode字符作为标记内容,这将欺骗构建规则,同时对为了注释而盲目坚持的东西进行轻微打击……

...至少直到他们引入了另一条规则来检查注释中的Unicode字符。

我在一家大型投资银行看到,该银行要求记录和评论所有应用程序中断

Without a crash 

Or mighty bang 

The sync disk 

Did it's process hang