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


当前回答

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!

其他回答

我不止一次使用过这个方法,当我对一个数学公式做了一些不明显的简化时,我不想记录:

//this formula is right, work out the math yourself if you don't believe me

在给一个朋友看了这篇来自《Coding Horror》的文章几个小时后,我看到了他对代码的评论:

// valdez先生是一个暴力的精神病患者。别惹他生气。

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

哪里喝醉了

// this is really complicated

没有其他评论了

return 1; # returns 1