ここに示すように、LCOMメトリックを見ています。
http://www.ndepend.com/Metrics.aspx
だから私たちはいくつかのことを言っています、
1) A class is utterly cohesive if all its methods use all its instance fields 2) Both static and instance methods are counted, it includes also constructors, properties getters/setters, events add/remove methods
このようなクラスを見ると、
public class Assessment
{
public int StartMetres { get; set; }
public int EndMetres { get; set; }
public decimal? NumericResponse { get; set; }
public string FreeResponse { get; set; }
public string Responsetype { get; set; }
public string ItemResponseDescription { get; set; }
public string StartText { get; set; }
public decimal? SummaryWeight { get; set; }
}
各ゲッターとセッターが「他のすべてのインスタンスフィールド」にアクセスしないため、0.94の悪いスコアを取得します。
このように計算されます、
accessAverage - methodCount / 1 - methodCount
(2 - 17) / (1 - 17) = 0.94 (rounded)
このメトリックを理解していませんが、なぜゲッターとセッターを含める必要があるのですか?ゲッターとセッターは常に1つのインスタンスフィールドにのみアクセスします。