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


当前回答

最初的《毁灭战士》拥有一个带有静态墙壁的引擎,但却不能移动;结果,所有的门都是垂直打开的;任何东西都不可能水平移动。当源代码发布后,我在查看代码时,在处理门的源文件中看到了这个,在一大块注释掉的代码的开头:

// 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)
//

其他回答

曾经有一个为我工作的程序员在他的代码中加入了“Style”注释,他在代码中编写了关于特定实现细节的内部争论,当他在某个特定的编码决策上被否决时,他就会离开。

例子:

的风格 '这是有争议的,但我传递图像句柄,而不是简单地 '传递缩放值,以保持调用代码更简单(通过a '一对声明语句)。或者,我可以传递这些数据 成员,但这将违反封装。

的风格 就像我在其他地方做过的一样,我将正式提出抗议 的表格),将注释序列化的实现视为 '一个属性,而不是一对Load/Save方法。这可能是 “风格的问题,值得商榷。

'Major changes: Everthing! - Removed all Cornoud's code !
try
{
...
}
catch(Exception ex)
{
//if this happens the world is going to end...
}

现在猜猜发生了什么……

//Dear future me. Please forgive me. 
//I can't even begin to express how sorry I am.  

我今天刚发现了这个:

//private instance variable for storing age
public static int age;
def format_ticket_content(text, recursive = true)
  if text.is_a?(TicketNote)
    note = text
    text = note.content
  else
    note = nil
  end

  ## Safety pig has arrived!
  text = h(text)
  ##                               _
  ##  _._ _..._ .-',     _.._(`))
  ## '-. `     '  /-._.-'    ',/
  ##    )         \            '.
  ##   / _    _    |             \
  ##  |  a    a    /              |
  ##  \   .-.                     ;  
  ##   '-('' ).-'       ,'       ;
  ##      '-;           |      .'
  ##         \           \    /
  ##         | 7  .__  _.-\   \
  ##         | |  |  ``/  /`  /
  ##        /,_|  |   /,_/   /
  ##           /,_/      '`-'
  ##