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


当前回答

I don't have the code to share, but imagine this scenario. About a month or two after our Linux Sys Admin left for greener pastures, I had the pleasure of opening a shell script he'd written. I can't recall why I needed to edit it, but that's not what matters. What's important is that the script was about 40 lines long. I scrolled past the commenting (of which there were 37 lines) to reach the actual working code (3 lines). The code was great, but I was curious - why 37 lines of commenting? So, I scrolled to the top and proceeded to read. To my surprise, the commenting was a rap about what the three lines of code did and how to change it. The best part - it was a partial rip off of Nothing But A G Thing by Dr. Dre and Snoop D O DOUBLE G. Thanks Brian!

其他回答

'Major changes: Everthing! - Removed all Cornoud's code !
/* FIXME This must absolutely be removed before 4.0.7 release
 * TODO really remove this */

我们已经发布了4.0.7,4.0.8,4.0.9和4.1版本…

// This is a walkaround for bug #7812

是我们的一个中国程序员写的,他的第一语言不是英语。

我真的很喜欢这个。我碰巧认为“walkaround”几乎比“workaround”更好。

当我注释掉我认为不再有用的代码块,但我可能是错的(因此没有删除它们),我有时会在它们之前

// Wilted celery?

这个想法就像芹菜一样枯萎了,但你还是把它放回冰箱里。我只知道十年后会有人看到这些评论,说什么鬼?

private int mousycounter = 0; //Not really a counter