95 95. Measures of well designed programs
The following are some metrics that can be used to see if a program is designed well:
Cyclomatic Complexity: Measures independent execution paths in a function. Lower is better.
Code Coverage: % of code exercised by automated tests. Aim ≥ 80%.
Coupling and Cohesion:
- Coupling: how interdependent modules are (lower is better)
- Cohesion: how focused a module’s responsibilities are (higher is better)
Lines of Code (LOC) per Method/Class: Monitors size; excessively large methods or classes often signal poor abstraction.
Maintainability Index: Combines LOC, complexity, and comment density into a single score.
Defect Density: Bugs per thousand lines of code; fewer indicates higher-code quality.
Technical Debt Ratio: Estimated “remediation cost” vs. development cost; lower ratios are healthier.
Static Analysis Warnings: Number/severity of linter or analyzer alerts per 1,000 LOC.
Code Churn: Frequency and volume of changes; high churn may signal instability or unclear design.
Documentation Coverage: Ratio of documented public APIs to total; measures how well the codebase is described.