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


当前回答

/// <summary>
/// The possible outcomes of an update operation (save or delete)
/// </summary>
public enum UpdateResult
{

    /// <summary>
    /// Updated successfully
    /// </summary>
    Success = 0,

    /// <summary>
    /// Updated successfully
    /// </summary>
    Failed = 1
}

其他回答

在一个巨大的800行'switch'语句中,在中间的某处:

// Joe is sorry

几百行之后……

// Harry is sorry too
//Woulda
if(x) {}
//Shoulda
else if(y) {}
//Coulda
else {}

以下是4个,排名不分先后:

// Father, forgive me, for I am sinning

// heaven help me

// horse string-length into correctitude 
(from a textbook)

// what, me worry?

我在重用我很久以前写的一个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;
}
//open lid


//take sh!t


//close lid

文件打开,数据转储,文件关闭…