Architecture/Source Code Inventory/Count Details

From Apache OpenOffice Wiki
Jump to: navigation, search

Counting CodeLines

The term "CodeLines" is somewhat ambigious, therefor one will find plenty of definitions which differ slightly, others are on their way to become something like a standard. For this reason we want to try to negotiate different terms and their meanings, to form a contract of how to understand it when we speak of CodeLines

How many Lines of code do we have here ?:

 No.      Code                        SLOC          DSI          Cmts         Descr.Cmts        Cmt Code
 --------------------------------------------------------------------------------------------------------
 01:  if ( my_function1() )             x            x
 02:   {                                x
 03:      //error handler                                         x              x
 04:  
 05:   return 1;                        x            x
 06:   }                                x   
 07:  // block of instruction 1                                   x              x
 08:  if ( my_function2() )             x            x
 09:    {                               x
 10:       //error handler                                        x              x
 11:  
 12:    return 2;                       x            x 
 13:    }                               x
 14:  // block of instruction 2                                   x              x
 15:  if ( my_function3() )             x            x
 16:    {                               x
 17:       //error handler                                        x              x
 18:  
 19:    return 3;                       x            x
 20:    }                               x
 21:  //  // block of instruction 3 + i                           x              x
 22:  //  if ( ... )                                              x                                 x
 23:  //    }                                                     x                                 x
 24:  //    ...                                                   x                                 x
 25:  //    }                                                     x                                 x
 26:
 27:
 28:
 29:
 30:

In my understanding we have here something like:

 30 LINES
 25 Lines of Code (LOC)
 12 Source Lines of Code (SLOC)
  6 Delivered Source Instructions (DSI)
 10 Comment Lines
  6 Descriptive Comments
  4 Lines Commented Code

Why is that ?

Lines

Some tools for static code analysis (i.e.RSM) count all blank lines even at the end of the file and would count here 30 Lines. Even when I do not really know why someone should do that I would like to differentiate that with the term LINES which is actually the number of CR/LF in a file.

Lines of Code (LOC)

25 is the actual number of Lines in this source without (trimmed by) the trailing blank lines expressed as LOC

Source Lines of Code (SLOC)

12 is the net count of code lines without comment lines and without blank lines. SLOC is actually the usage part for the compiler.

Delivered Source Instructions (DSI)

6 is the net count of instructions delivered to the customer. This term omitts, in addition to SLOC, lines with single curly brackets and is therefor not affected by coding style. This is what RSM calls eLOC (effective Lines of Code). If I would have to pick one code metric it would be DSI. Some tools may count the open curly bracket but not the closing one. Convince me.

Comment Lines

10 is the umber of lines with comments, regardless if we encounter a multi line comment, commented code, comment delimiters etc.

Descriptive Comments

According to a smarter algorythm the comment lines are analyzed to figure out multi line comments or headers which count as one descriptive comment as well as filter comment delimiters or ascii art. Doing so you will count 6 DC

Lines Commented Code

Identifies and count code sections which are commented for some reasons. These are potential opportunities to dig into the code for consolidation purposes, as you may find 4 Lines Commented Code here.

Personal tools