Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "Depth of Inheritance" mean for methods?

I have just installed the Visual Studio Power Tool for code analysis and the viewer for the results. Great tools, by the way!

When I click "Analyze Solution" I get the results:

  • Maintainability
  • Cyclomatic Complexity
  • Depth of Inheritance
  • Class Coupling
  • Lines of Code

I understand what these all mean, except that there are different values of "depth of inheritance" for each method in a class, and a larger one for the class.

Does anyone have an explanation of what this might be saying?

like image 876
Peter K. Avatar asked May 18 '11 22:05

Peter K.


People also ask

How do you calculate the depth of inheritance of a tree?

Method of calculation the Depth of Inheritance Tree is the maximum level reached by walking the dependency tree of A, then B1 and B2, recursively so until an element is encountered which does not Extends anything.

What is a good maintainability index?

=> 85 - Highly Maintainable. 65 - 85 - Moderately Maintainable. <= 65 - Difficult to Maintain.

What is calculate code metrics in Visual Studio?

Developers can use Visual Studio to generate code metrics data that measure the complexity and maintainability of their managed code. Code metrics data can be generated for an entire solution or a single project.

What is class coupling in code metrics?

Basically, class coupling is a measure of how many classes a single class uses. A high number is bad and a low number is usually good with this metric. Class coupling has been shown to be an accurate predictor of software failure and recent studies have shown that an upper-limit value of 9 is the most efficient S2010.


1 Answers

As each derived class extends the previous class, it adds additional functionality. It can add properties or methods that didn't exist in the previous base class. Now the the total set of methods is larger than it was for the base class. This process can be repeated when the derived class is derived from again.

So if you take the most derived class and pick a method A and follow it down to the base class that first implemented A, it might be a different deeper class than if you pick method B and follow it down to the first base class that implemented B. This is why the depth of inheritance can be different for different methods.

If you take the class itself, it has a clear series of base classes and a clear depth of its own, independent of the depth of the methods, which are always the same or less the class itself.

like image 57
Rick Sladkey Avatar answered Oct 03 '22 08:10

Rick Sladkey