What does "Depth of Inheritance" mean for methods?
Asked Answered
B

2

10

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?

Braeunig answered 18/5, 2011 at 22:15 Comment(0)
B
5

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.

Bronchiole answered 18/5, 2011 at 22:51 Comment(1)
Thanks, Rick! That's what I was thinking, but it wasn't clear to me in the example I was looking at.Braeunig
G
3

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

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

Glassman answered 18/5, 2011 at 22:18 Comment(5)
That link does not discuss depth of inheritance for methods, which is what the question is.Bronchiole
In addition to what Rick said, if I could also make a suggestion. Using a link to help answer the question is great. But, if the link ever disappears (as links tend to do on the internet), we have no knowledge of what it said. Instead, pull out the pertinent points of the link and quote them within your answer. This way, everybody can get an answer, it's stored with the question, and if people want more depth, they can go directly to the link.Highway
It is a great picture! I do understand depth of inheritance. Where I was coming unstuck was the different values of it on methods of the same class.Braeunig
@trante Thanks for the heads up. I found what appears to be the place where that post was moved. I kept the original link, since you can look that up on archive.org but I added the new link to the post. Thanks again.Glassman
And the updated link is now gone. Archive.org version hereBraeunig

© 2022 - 2024 — McMap. All rights reserved.