Peter K.
Peter K.

Reputation: 8108

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:

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?

Upvotes: 10

Views: 4680

Answers (2)

IAmTimCorey
IAmTimCorey

Reputation: 16755

Here is a great explanation (with pictures!) of Depth of Inheritance:

http://www.nayyeri.net/depth-of-inheritance-for-wpf-and-windows-forms-applications

Upvotes: 4

Rick Sladkey
Rick Sladkey

Reputation: 34250

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.

Upvotes: 5

Related Questions