I'm trying to understand how the elementary class structural metrics, such as ATFD (access to foreign data) and LCOM (lack of cohesion in methods) are calculated in light of C# Properties.
If a method access a single property of another class, does that mean that the ATFD score of that method is 1? Does this change based on whether there is a backing private field or not?
For LCOM, does the property count as a field or as a method (or as both) when following the formula laid out by NDepend for example https://www.ndepend.com/docs/code-metrics#LCOM.
How does this change when we have an explicit private field related to the property - i.e., what is the LCOM difference for the following classes A and C:
class A {
private int _b;
private int _bx;
public int B { get { return this._b; }
set { this._b = value; }
}
public void MethodA() {
B = 1;
}
public void MethodB() {
this._bx = 1;
}
}
class C {
public int B { get; set; }
public int Bx { get; set; }
public void MethodA() {
B = 1;
}
public void MethodB() {
Bx = 1;
}
}