Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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 -

MethodCyc. Compl.LOCBlank linesComment linesComment %Statements
GenMoves504372311426.09236
FENToPosition41117182723.0899
IsAttacked26193177438.34102
PieceToString1621000.0032
ColourOfPiece1416400.004
PieceToString1015000.0020
HitTheEdge1031900.0010
ASCToFEN95361935.8526
FirstBit8391000.0021
MoveToString828100.0017
Slide5256416.0015
GetMoveCount421600.0012
PrintMoveList25000.002
LeftEdge14000.002
RightEdge13000.001
TopEdge13000.001
BottomEdge13000.001
SquareToString13000.001
SquareToString13000.001
SquareToRank13000.001
SquareToFile13000.001
ASCToPosition13000.001
Warn13000.001

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.

 


In reply to Re^2: Cyclomatic Complexity of Perl code by EdwardG
in thread Cyclomatic Complexity of Perl code by ryanus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (11)
    As of 2014-09-18 21:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (124 votes), past polls