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


当前回答

我尤其对此感到内疚,在我的大多数项目中嵌入了非建设性的注释、代码诗歌和小笑话(尽管我通常有足够的理智在发布代码之前删除任何直接冒犯的内容)。这里有一个我特别喜欢的,放置在一个设计很差的“上帝物体”下面:

/**
* For the brave souls who get this far: You are the chosen ones,
* the valiant knights of programming who toil away, without rest,
* fixing our most awful code. To you, true saviors, kings of men,
* I say this: never gonna give you up, never gonna let you down,
* never gonna run around and desert you. Never gonna make you cry,
* never gonna say goodbye. Never gonna tell a lie and hurt you.
*/

我很抱歉! !我就是忍不住.....!

还有一个,我得承认我还没有真正把它放出来,尽管我很想在我的一个不那么直观的课上这么做:

// 
// Dear maintainer:
// 
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
// 
// total_hours_wasted_here = 42
// 

其他回答

$dnstime = time() + 60 * 60 * 24 * 7 * 2; //how long are you staying for vacation on mars? twooo weeeeeks. give dees people air
/*
* Wirzenius wrote this portably, Torvalds fucked it up :-)
*/

我最喜欢的(我必须承认我用过很多次):

// Yes...I know this is repulsive and stupid.
// But <%CompanyOwnerOrManagerToken%>, not knowing a thing about code,
// demanded I do it anyways. SO, go crap on their desk, not mine.
// K THX BYE 
// TODO: Drive an ashen stake through the foul heart of this function.

这是一个糟糕的函数。直到今天我还在做噩梦。

#pragma region Crap that is kept for temporary reasons

    //  Huge chunk of commented code

#pragma endregion