你遇到过的源代码中最好的注释是什么?
当前回答
最初的《毁灭战士》拥有一个带有静态墙壁的引擎,但却不能移动;结果,所有的门都是垂直打开的;任何东西都不可能水平移动。当源代码发布后,我在查看代码时,在处理门的源文件中看到了这个,在一大块注释掉的代码的开头:
// UNUSED
// Separate into p_slidoor.c?
#if 0 // ABANDONED TO THE MISTS OF TIME!!!
//
// EV_SlidingDoor : slide a door horizontally
// (animate midtexture, then set noblocking line)
//
其他回答
/*
____________________
/ \
| Jean-Michel Bechet |
| 2002-2009 |
\___ _______________/
|/
(o_
//\
V_/_
*/
刚从大学毕业的我渴望亲自动手。我的第一个任务是……“为我注释此代码”。
傻瓜。
过了一段时间我就厌倦了……
// this function doesn't actually calculated the profit, like it says --it really signals the mothership orbiting saturn that the planet is ripe for takeover
[later]
// I don't think anyone is going to read this
[various permutations on that last one]
我在重用我很久以前写的一个PHP类时发现了这一点。我仍然不记得那里有什么,我仍然发现它没有任何用处……我甚至不记得我写过那篇评论;所以当我找到它的时候,我真的笑出声来了。
try
{
// Some database logic
}
catch (Exception $ex)
{
// sure, it looks silly and I honestly cant remember what code used to go here... but i swear i will
// find a use for this code.... eventually....
throw $ex;
}
对于我编写的memcache包装器/处理程序接口模式类,我实现了以下方法。
/**
* Do not use, ever - left in place for testing purposes
*/
function I_David_WillHuntYouDownAndHurtYou_Badly_IfIFindThisUsedAnyWhereInTheAppLibrary(){
...
}
这基本上是一个超级核函数,它告诉所有单独的memcache服务完全刷新自己,并从我用于键的单个名称空间计数器(例如{_counter_key value}_)重新开始。{_counter_key value})
Another minor novella I wrote was for an automated downloader for a data vendor, detailing how much I hated this vendor and went to great lengths of postulating that their infrastructure's batch system was run by a gerbil, running on a wheel and after so many revolutions of the wheel the next queued task would be started. It was written over the course of 6 months of adding additional exception handling, estoric checks like ( if we got 768 Bytes of \s characters, that means the query to their DB timed out and the spaces are the result of empty failure print statements.
.class {border:1px solid gold;} /*我可怜这个傻瓜*/