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


当前回答

options.BatchSize = 300; //Madness? THIS IS SPARTA!

其他回答

这一点对其他人来说很有趣,但对我来说就不那么有趣了。我从一个开发人员那里继承了代码(ASP),而他自己也继承了它。第一个程序员编写了一些很难理解的代码。第二个开发者添加了如下评论(为了保护不那么无辜的人,名字被隐藏了):

'This code was written by **************.
'I haven't a clue what it does. He hasn't a clue what it does.
'Nobody else has a clue what it does or how it does it.
'It is something to do with data but **** knows what.
'The ******* still works so please do not change this code,
'even though it is a complete pile of ****.

那我为什么不觉得有趣呢?嗯,这是一个客户内部网的ASP代码。

...正是那位顾客向我强调了这条评论。

:-(

// John! If you'll svn remove this once more,
// I'll shut you, for God's sake!
// That piece of code is not “something strange”!
// That is THE AUTH VALIDATION.

你怎么看?下面的代码是安全的“svn删除”。

我在查看TVNZ网站早期迭代的HTML源代码时发现了这个宝藏(如果你在家玩的话,从571行开始):

<!-- Hopfully we can do this otherwise the nav is going to be pretty plain and Hong will go postal. -->
// nobody read comments!

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!