CodeImprover Technical Reference

Metric Name:

Number of public methods

What:

This metric measures how many public methods an interface or a class exposes.

Default setting:

Any public methods or class with more than 7 methods triggers negative Observation Score points.

Why:

If an interface or a class exposes a high number of methods, it often indicates that the interface defines too big responsibility or a class that takes care of too many tasks. This often decreases maintainability.

What to do:

Consider refactoring the interface/class to more interfaces/classes where each has a smaller responsibility/fewer tasks.


Context – How it works
Back to – Metrics reference overview