I empathise with your tales of woe, but I think you go too far in dismissing the value of metrics as source code instrumentation.
If one considers a given metric to be part of the whole picture, but at the same time does not confuse the single metric for the whole of the picture, I think metrics can help a great deal, particularly when dealing with large volumes of code, and large numbers of coders, and particularly in terms of informing decisions about where to spend code review and unit test effort.
It sounds like you have suffered from idiotic applications of misguided rules more than you have suffered from the metrics themselves, but perhaps that is the price of their existence; that they will be abused like so much else.
Out of interest, I generated these metrics for a part of my hobby chess engine -
|Method||Cyc. Compl.||LOC||Blank lines||Comment lines||Comment %||Statements|
As a profile of this part of the engine, I found this very interesting. For instance,
- why do four of the complex methods have no comment lines at all?
- Why is FENToPosition so complex? (this was a surprise)
- Is Slide() under-commented at 16%?
- What (if any) is the correlation between lines of code (LOC) and Complexity?
- Is this consistent with other code I've written?
- How do all these stats compare to other projects?
- Does this align with my intuitive sense of their complexity?
- Is there a code density metric I can derive from LOC and statements?
Now some of these thoughts I could have had by simply browsing the code, but I hope I'm illustrating the usefulness of these metrics as a high-level view. I find them provocative in a highly beneficial way.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link
or How to display code and escape characters
are good places to start.