WOC — Weight of Class
Class Metric | AST-based
The ratio of public attributes to all public members (attributes + methods). Values near 1 indicate a data-container class; values near 0 indicate a behaviour-heavy class.
Formula
WOC = public_attributes / (public_attributes + public_methods)
Result is in [0, 1]. Returns 0 when the class has no public members.
Visibility rules
A member is public when:
- It has an explicit
publicmodifier, or - It has no accessibility modifier at all (TypeScript default is public).
Members with private, protected, # (private field), or readonly-only are excluded.
TypeScript Example
class Config {
public host: string; // public attr
public port: number; // public attr
private secret: string; // excluded
getUrl(): string { ... } // public method
}
// public_attrs=2, public_methods=1 → WOC = 2/3 ≈ 0.67
Thresholds
WOC is informational — it is not threshold-checked directly. It feeds the God Class strategy (high WMC + low TCC + high ATFD).
Related metrics
WMC · TCC · NOM · God Class strategy