C# - 在课堂陈述之前或之后发表评论?

时间:2014-08-23 15:22:46

标签: coding-style comments

我最近看到一个系统在注释项之前使用词汇表一致地放置C#注释。例如:

/// <summary>
/// The pool of relative sequence ids used by the model.
/// Initially set to {1..Parameters.creditGoal}. Elements 
/// will be removed and put into the sequence window as credit
/// is acquired, and put back into the pool when they have been used. 
/// </summary>
static SetContainer<int> sequenceIdPool;

/// <summary>
/// Asserts a requirement with associated requirement description.
/// </summary>
/// <param name="condition"></param>
/// <param name="id"></param>
/// <param name="description"></param>
static void Requires(bool condition, int id, string description)
{
    Condition.IsTrue(condition, MakeRequirementId(id, description));
}

这看起来很奇怪,也是可读性的障碍。我想不出写主题标识符(A-head,B-Head等)在详细信息之前的写作风格。

所以,我宁愿看到一个评论栏紧跟其描述的项目,例如,

static void Requires(bool condition, int id, string description)
/// <summary>
/// Asserts a requirement with associated requirement description.
/// </summary>
/// <param name="condition"></param>
/// <param name="id"></param>
/// <param name="description"></param>
{
    Condition.IsTrue(condition, MakeRequirementId(id, description));
}

问题:是否有任何技术理由支持在其主题之前放置评论块?

1 个答案:

答案 0 :(得分:0)

嗯,就我个人而言,我从未在目标之后看过任何评论。至于我,它看起来很奇怪。关于技术原因 - 例如,Visual Studio IntelliSense无法识别目标后面的注释。