Which metric(s) could help to indicate that i have procedural code instead of object-oriented code? I would like to have a set of simple metrics, which indicate with a high probability, that the analyzed code contains procedural transaction scripts and an anemic domain model instead of following sound object-oriented design principles.
Would be happy about any set of useful metrics and tools for measuring.
Thanks, Thomas!
Some just out of my mind
These don't ensure your code is more OO or more procedural, but might find helping those.
Metrics focused on cohesion and coupling should give a good indication that your classes are real as opposed to collections of functions. There's a very readable paper here which I quote below to indicate why I think cohesion is a good metric:
"Cohesion refers to the relatedness" of module components. A highly cohesive component is one with one basic function. It should be difficult to split a cohesive component. Cohesion can be classified using an ordinal scale that ranges from the least desirable category (coincidental cohesion) to the most desirable (functional cohesion)."
The classic measurement of cohesion is Chidamber and Kemerer's "Lack of Cohesion in Methods" (LCOM). You can also look at Response for a Class (RFC) which measures the linkage between methods in a class.
You could consider design metrics such as NOC and DIT but my own experience is that they are too crude and easily confused by classes within a third-party framework.
You haven't said which language you use but there are some tools built around Eclipse so a quick web search for Eclipse based object oriented metrics should yield something useful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With