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


当前回答

// Any maintenance developer who can't quote entire Monty Python
// movies from memory has no business being a developer. 
const string LancelotsFavoriteColor = "$0204FB"

其他回答

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!

我刚刚在一些遗留代码中发现了这个..

'CANNOT JUST QUIT!
// Singleton object. Leave $me alone.
private static $me;
// error codes
#define ERROR_SUCESS 0
#define ERROR_SUCCESS_IS_MISSPELLED 1

没有定义其他错误代码。

来自Linux内核源代码:

linux /包括/ asm-i386 / hw_irq。h:

/*
 * subtle. orig_eax is used by the signal code to distinct between
 * system calls and interrupted 'random user-space'. Thus we have
 * to put a negative value into orig_eax here. (the problem is that
 * both system calls and IRQs want to have small integer numbers in
 * orig_eax, and the syscall code has won the optimization conflict ;)
 *
 * Subtle as a pigs ear.  VY
 */