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


当前回答

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

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

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

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

其他回答

好吧,这些是我的,所以WTF是我,正如CodingHorror所说:

//#region Code for weird cases - do you really want to know?

我曾经在一些ASP中留下了这样的评论:

' Commented out following code, don't delete for when [CustomerName] changes his mind

碰巧,[CustomerName]没有改变他的想法,但他确实有访问web服务器,他确实找到了那行…

' Oh man I'm pissed. I think I better go home.

哪里喝醉了

从Joomla !来源:

// fudge the group stuff
// StupidCompilerDontInline(SCDI), in the test project where
// allcode was in a single cpp the compiler had inlined nearly
// everything which lead to nice stackoverflow.
// To prevent this the metods are made virtual
#define SCDI virtual
// I love the smell of dirty XML in the morning
xml = xml.Replace("xmlns=\"urn:bsd.orion/inventory\"", "");