开发者

Metric to measure object-orientedness

Is there a metric that can assist in determining the object-orientedness of a system or applicatio开发者_Go百科n? I've seen some pretty neat metrics in the .NET Reflector Add-ins codeplex project, but nothing like this yet. If such a metric doesn't exist, would it even be possible or useful? There are the 3 supposed tenets of object-oriented programming: encapsulation, inheritance, and polymorphism; a tool that ranked programs against these might be able to show areas of a C# (or similar) code base where the whole object-oriented ideal was discarded, and perhaps how many bugs are associated with that area versus the rest of the project.


One meaningful interpretation of a good OO design is that objects in a design map logically and consistently to the domain objects being modeled. Interpreting this requires a deep knowledge of the problem you're trying to solve, including the overall context. Automated metrics are not yet sophisticated enough to understand context in this way.


In response to the comment, I thought I would expand a bit:

The main point I was hoping to make is that OO is not 'encapsulation, inheritance and polymorphism'. Those are just tools that enable modeling of a problem as objects that interact in well-defined ways. If you want a good metric, you need to understand what you're really trying to measure. It sounds like you're trying to validate a 'gut feel' notion of code quality with a metric to back up the feeling. If that's the case, what's the real underlying concern? Are you worried the code is brittle and likely to break easily due to unexpected side effects? Is the object model too fragmented and hard to follow? Are the individual objects too large to understand and maintain? If you can define better the kinds of flaws you're hoping to to identify, it will help you to find appropriate metrics. In case they are helpful, here is one useful set of metrics.


Have a look at the 82 code metrics definitions supported by the tool NDepend for .NET developers.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜