We always face interesting discussion on code matrices. I
got a funny but very interesting understanding of the types of metrices and its
prioritization that we always talk about. I would spread code metrics into two
categories,
- Code matrices that can be identified with bare eyes by a developer.
- Code matrices that cannot be identified with bare eyes by a developer.
Code matrices that can be identified with bare eyes are
- Unused types
- Depth of inheritance
- Code comments etc.
The above matrices can be identified by a developer while
coding or refactoring and he can react on them immediately. For example, if he
/ she see an unused import he / she can delete it. He / she does not have to
wait for a tool to detect it or to Google for a new tool to recognize this
measure. Same applies for code comments, do not write comments if you find any irrelevant
comment delete them right away.
Code matrices that cannot be identified with bare eyes are
- Test coverage
- Cyclomatic complexity
- Package cycles
- Duplicates etc.
The above matrices can not be identified by a developers using
his bare eyes. These are not easily detectable by the developer. These matrices
are calculated based on some formulas or these are not a very straight forward
calculations. Test coverage you cannot identify while coding you have to use
some tools to identify that. Similarly cyclomatic complexity you may not be able
to identify while coding or may not be interested to invest more time on that.
So in these cases we need a tool to measure these matrices and maintain a standard
count.
Hence matrices that really needs tools to recognize should
be prioritized first and then others. Matrices like code comments, unused types
can be of least priority as it is easily detectable and fixable.
Comments
Post a Comment