开发者

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 So开发者_JAVA技巧lution" 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?


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.


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜