NDepend.API Documentation
LCOM Property
NDepend.CodeModel Namespace > IType Interface : LCOM Property
Gets a numeric nullable value assessing the class members cohesion, through the standard Lack of Cohesion Of Methods code metric.
Syntax
Nullable<float> LCOM {get;}

Property Value

null if this type is declared in a third-party assembly.
null if this type is an interface or an enumeration.
Otherwise returns this type LCOM numeric value.
Remarks
The single responsibility principle states that a class should not have more than one reason to change. Such a class is said to be cohesive.
A high LCOM value generally pinpoints a poorly cohesive class. There are two LCOM metrics.
Here are algorithms used by NDepend to compute LCOM metrics:
Where:
The underlying idea behind these formulas can be stated as follow: a class is utterly cohesive if all its methods use all its instance fields, which means that sum(MF)=M*F and then LCOM = 0 and LCOMHS = 0.

Recommendations:
Types where LCOM > 0.8 and NbFields > 10 and NbMethods >10 might be problematic. However, it is difficult to avoid such non-cohesive types.
Types where LCOMHS > 1.0 and NbFields > 10 and NbMethods >10 should be avoided. Note that this constraint is stronger (hence easier to satisfy) than the constraint types where LCOM > 0.8 and NbFields > 10 and NbMethods >10.
Requirements

Target Platforms: Windows 11, 10, 8, 7 and Linux, MacOS with net8.0, net7.0 or net6.0 installed

See Also

Reference

IType Interface
IType Members