Number Of Levels

This metric is an indication of the maximum number of levels of nesting in a method. The idea of the metric is that a large Number Of Levels increases complexity and reduces comprehensibility. In addition, such methods generally (but not necessarily) operate at the lowest level of abstraction or at mixed levels of abstraction, both of which contribute to the confusion.

All methods that have a large Number Of Levels can be simplified by extracting private methods or by creating a Method Object. Both of these result in naming of the different parts of the original method, thus raising the level of abstraction.

Note that the Number Of Levels metric and the degree of indentation of the code are not necessarily the same. Consider the case of cascaded 'if/else if' statements. Each 'else if' is another level of nesting but this is not usually the way it is displayed in source listings.


This plugin is provided by State Of Flow