你遇到过的源代码中最好的注释是什么?
当前回答
我看到有人对代码的评论:
// This comment is self explanatory.
我猜他是想说“可变的”,但这个错误造成了一个有趣的评论……想想这里的循环逻辑,以及写它的徒劳。
其他回答
#Christmas tree initializer
toConnect = []
toRead = [ ]
toWrite = [ ]
primes = [ ]
responses = {}
remaining = {}
为什么你不应该将你的软件开发外包的一个经典案例:
public class Contact
{
//...
/// <summary>
/// Gets or sets the name of the first.
/// </summary>
/// <value>The name of the first.</value>
public string FirstName
{
get { return _firstName; }
set { _firstName = value; }
}
}
在大学的一次家庭作业中,一位老师特别坚决地要求我们注释代码:
//I wonder if she actually reads these.
当作业被返回时,在注释“是的,我愿意”旁边用红笔写着
/*************************** Drag And Drop Section - Start (you should be me to mess with this section)*********************************************/
在头文件的顶部:
/* Project : XYZ (Please somebody shoot me!)
*
* File : $Id: defs.h,v 1.1 $
*
* Purpose : Create havoc rather than peace among many nations
*
* History : Back-ported changes that were not in CVS. Please somebody,
* shoot us and put us all out of our misery.
*/
“XYZ项目”(已改名)是一个长达七年的折磨。最后这句话是由一个从头到尾都参与其中的坚定的灵魂写的。