Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mehen.ophi.dev/llms.txt

Use this file to discover all available pages before exploring further.

NPM (Number of Public Methods) counts the public methods exposed by classes and interfaces in a file. NPM is the size of the unit’s API surface.

What mehen emits

KeyTypeDescription
npmintTotal public methods across classes and interfaces.
npm.classesintNPM contributed by classes.
npm.interfacesintNPM contributed by interfaces.
npm.class_methodsintAlias of npm.classes.
npm.interface_methodsintAlias of npm.interfaces.
npm.classes_averagefloatMean public methods per class.
npm.interfaces_averagefloatMean public methods per interface.
npm.total_methodsintAlias of npm.
npm.averagefloatMean public methods per declaration.
Despite the name, this metric has nothing to do with the npm package manager. NPM here stands for Number of Public Methods, a classic CK-style object-oriented metric.

What counts as “public”

LanguagePublic method is…
Java / KotlinA method declared public (or with no modifier in Kotlin).
TypeScript / JSA class method without private / protected / # prefix.
PythonA method that does not start with _.
RubyA method not declared private or protected.

How to read it

Conventional reading:
npmInterpretation
1–10Small, focused class.
11–25Normal application class.
26+God-class candidate.
Pair with WMC to gauge whether the surface is wide and heavy, and with NPA to gauge whether the class encapsulates state.

References

  • Lorenz, M. & Kidd, J. (1994). Object-Oriented Software Metrics: A Practical Guide. Prentice Hall.
  • Chidamber & Kemerer (1994). A Metrics Suite for Object Oriented Design. IEEE TSE.

See also

  • NPA — number of public attributes.
  • NOM — total methods (public + private).
  • WMC — weighted methods per class.