SLOC was Re: [SATLUG] PHP Eats Rails for Breakfast

Bruce Dubbs bruce.dubbs at gmail.com
Tue Dec 5 12:45:29 CST 2006


Justizin wrote:

> So, I could challenge your question with another:
> 
>  What in the hell does a raw SLOC count tell you, at all? ;)

OK, now we are getting somewhere.

Of course SLOC by itself is not definitive.  Its like saying that a book
has 100 pages or 1000 pages.  It says nothing about the language,
content, quality of writing, redundancy, importance, etc of the book.

What SLOC does is give you a measure of size.  This measure of size can
used to manage software development and maintenance.  Studies have shown
that SLOC written per day is fairly constant for an individual
programmer regardless of language (but not regardless of application
domain).  Individual programmer productivity also falls into a range
that can be measured.  If you can estimate the size of a project by
various measures, such as expert estimation, comparison with other
similar projects, etc, you can estimate the time and number of
developers needed to write or maintain a project.

Is this method perfect?  No, of course not.  Is it better than a wild
guess?  Almost certainly.  Is there something better?  In some specific
domains, perhaps, but I don't know of any that are better as a first
order estimation of size.

Perhaps it would be better to to discuss what exactly *is* a SLOC.  In
many ways it is like a sentence.  It produces a thought.  Programmers
think in terms of writing "lines of code"  -- not characters, not
punctuation, not identifiers.  For instance, if I write:

  a = b * 10;

that is a thought.  You understand it.  I understand it.  We communicate
with each other.  The compiler breaks this down and produces several
machine instructions, bu that is irrelevant to the thought processes of
programmers.

In the same way, if I do:

  c = (char*)malloc(1000);

or even:

  <p>When in <b>the course</b> of human events...</p>

you understand these too.  They also conveys a thought, but do a lot
more than the first example.

Measuring lines of code is not trivial.  It is far more than doing:

  wc -l *.c

Do you count blank lines?  Do you count comments?  What about included
(or copied) code?  Modified code?

The bottom line is that SLOC is like most measures.  It can be used for
valid purposes or misused.  It is much better when used within a single
organization with a well thought out definition.  The issues go far
beyond "good" or "bad".

  -- Bruce



More information about the SATLUG mailing list