views:

35

answers:

1

I'm reading xUnit Test Patterns by Gerard Meszaros.

On one of the pages he refers to some software metrics:

While the need to wrap lines to keep them at 65 characters makes this code look even longer than it really is, it is still unnecessarily long. It contains 25 executable statements including initialized declarations, 6 lines of control statements, 4 in-line comments, and 2 lines to declare the test method—giving a total of 37 lines of unwrapped source code.

Short of counting the statements to find these metrics, does anybody have any idea if he used a particular tool to calculate the metrics?

(If you have any suggestions for tools that will count similar metrics, I'm looking for one that works on Java, Javascript and C++)

Thanks!

+1  A: 

Sorry to disappoint you but I did count by hand (well, by eye). It's only 25 lines of code! I just went through and counted semi-colons and subtracted lines that weren't acutally executed (like uninitialized variable declarations.)

The point is not exactly how many lines of code there are but rather how much fewer lines of code you need to write (once) and read/understand/modify (many times).

Gerard

Gerard Meszaros
Oh okay, I knew that the number of lines of code weren't important; but I didn't know if the number of different types of statements: executable statements, control statements mattered or not.Perhaps I'm thinking too hard on this.Welcome to Stack Overflow by the way; we're glad to have you here!
leeand00
Do those kind of code-metrics matter? I've seen a couple of projects where they count things such as this (instead of lines of code).
leeand00
(that's what gave me the idea to look for a tool like that in the first place)
leeand00