Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > lines of code?

Reply
Thread Tools

lines of code?

 
 
Digital Puer
Guest
Posts: n/a
 
      11-29-2003
I have two questions about the metric of 'lines of code':


1. How do you actually count this? On a Unix box, I can run 'wc -l'
to get the lines, but of course this includes comments and blank lines.


2. What is a fair number of lines of code in a one-man project that
would show decent proficiency (i.e. for a job interview)?
5000? 10,000? 100,000?


Thanks for any info.

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      11-29-2003
"Digital Puer" <> wrote in message
news:bqb7b1$uu9$...
> I have two questions about the metric of 'lines of code':

....
> 2. What is a fair number of lines of code in a one-man project that
> would show decent proficiency (i.e. for a job interview)?
> 5000? 10,000? 100,000?


If you could reduce a 100,000 line program to 5,000
lines without losing clarity in the code or introducing bugs..

_That_ shows proficiency..

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


 
Reply With Quote
 
 
 
 
nos
Guest
Posts: n/a
 
      11-30-2003
we would always use NCSL
"non commentary source lines"
for our "C" programs
a physical line could contain
1. source code only
2. comment only
3. some of each
we would add up from 1 and 3
however, there is some fudge, for example with eclipse I have
in a current java program the following
------
out.println("<table width=700 border=1 cellpadding=1 cellspacing=0>");
out.println(
"<tr bgcolor=#ff6666><td>"
+ (++cnum)
+ "</td><td>&nbsp;</td><td><b>"
+ cn
+ "</b></td></tr>");
------
when I typed it in, the second statement was 2 lines
but now it is 6
so it depends on whether you want to give your boss
a big number or a small number

"Digital Puer" <> wrote in message
news:bqb7b1$uu9$...
> I have two questions about the metric of 'lines of code':
>
>
> 1. How do you actually count this? On a Unix box, I can run 'wc -l'
> to get the lines, but of course this includes comments and blank lines.
>
>
> 2. What is a fair number of lines of code in a one-man project that
> would show decent proficiency (i.e. for a job interview)?
> 5000? 10,000? 100,000?
>
>
> Thanks for any info.
>



 
Reply With Quote
 
pete kirkham
Guest
Posts: n/a
 
      11-30-2003
Digital Puer wrote:
> I have two questions about the metric of 'lines of code':
>
>
> 1. How do you actually count this?

For C++ and Java, I have been known to take either the number of
semicolons, or the number of semicolons plus the number of asterices.

> 2. What is a fair number of lines of code in a one-man project that
> would show decent proficiency (i.e. for a job interview)?
> 5000? 10,000? 100,000?


I work in R+D for the aerospace industry, so my first professional one
man project involved 400,000+ semicolons (excluding wizard generated
code, and about 250,000 lines made it into production release; that's
the total code that made up all the releases on the project). That
project I was the sole C++ developer creating a experimental toolset for
a group of a dozen engineers over a few years - if there were a dozen
people working on it, then they would just be sitting waiting for the
users to feed back. Most other areas of software are less experimental
and have most of their requirements fixed up front, so can be
implemented by teams on a shorter timescale. Aerospace projects are very
long and thin in comparison.

nos wrote:
> we would always use NCSL
> "non commentary source lines"
> for our "C" programs


A more recent project, I was writing an algorithm in C to demonstrate a
deterministic solution to automated collision avoidance in cluttered
airspace. The code is given to the customer to allow it to be ported
onto a realtime, safety critical subsystem. It's highly mathematic, so
contains about 3 lines of comment to one of procedural code - otherwise
it's impossible to follow (if I write something like that without
commenting it, after a month I can't tell what's going on; plain text
based languages don't capture the meaning of math well). That ratio is
fairly typical of critical mathematical code that is intended to be
maintainable. Other languges, such as Spark-ADA, use special comments to
additionally specify the contract of an interface and side effects of a
function.

In non-math applications you often don't need so much explanation, and
higher level languages that are closer to the domain language require
fewer, but the comments should be part of the metric you are using to
mesasure output.

If you don't give value to comments, you are encouraging your developers
to make less maintainable code.


Pete

 
Reply With Quote
 
Joona I Palaste
Guest
Posts: n/a
 
      11-30-2003
Digital Puer <> scribbled the following
on comp.lang.java.programmer:
> I have two questions about the metric of 'lines of code':


> 1. How do you actually count this? On a Unix box, I can run 'wc -l'
> to get the lines, but of course this includes comments and blank lines.


First you have to decide what constitutes a line of code. Is this a
line of code?

foo(); bar();

What about this?

someFieldSomeWhere=thisIsAReallyLongVariableName.t hisIsAReallyLongMethodName
(firstParameter, secondParameter).anotherMethod()!=
A_CONSTANT_WITH_A_REALLY_REALLY_LUDICROUSLY_LONG_N AME;

--
/-- Joona Palaste () ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A computer program does what you tell it to do, not what you want it to do."
- Anon
 
Reply With Quote
 
EventHelix.com
Guest
Posts: n/a
 
      11-30-2003
> 1. How do you actually count this? On a Unix box, I can run 'wc -l'
> to get the lines, but of course this includes comments and blank lines.


The only requirement here is consistency. If you use wc -l for
your entire project, that's fine.

Another mechanism for counting lines of code is to count total number
of semi-colons ( and closing-braces (}).

Sandeep
--
http://www.EventHelix.com/EventStudio
EventStudio 2.0 - System Architecture Design CASE Tool
 
Reply With Quote
 
Jeffrey Palm
Guest
Posts: n/a
 
      11-30-2003
Digital Puer wrote:
> I have two questions about the metric of 'lines of code':
>
>
> 1. How do you actually count this? On a Unix box, I can run 'wc -l'
> to get the lines, but of course this includes comments and blank lines.


I use this script:

my $total = 0;
my $FORMAT = "%-40s%10d\n";
foreach $infile (@ARGV) {
open(infile, "<$infile") || die "Cannot open $infile:" . $!;
my $cnt = 0;
loop: while (<infile>) {
chomp;
s/^\s+//g;
s/\s+$//g;
foreach $a ("{","}","") {
next loop if $_ eq $a;
}
my $loc = tr/;//;
$cnt += $loc && !/^for/ ? $loc : 1;
}
printf $FORMAT, $infile, $cnt;
$total += $cnt;
close(infile);
}
print "-"x50 . "\n";
printf $FORMAT, "TOTAL", $total;


> 2. What is a fair number of lines of code in a one-man project that
> would show decent proficiency (i.e. for a job interview)?
> 5000? 10,000? 100,000?
>
>
> Thanks for any info.
>



--
Jeffrey Palm --> http://www.ccs.neu.edu/home/jpalm

 
Reply With Quote
 
Joe Wright
Guest
Posts: n/a
 
      11-30-2003
Digital Puer wrote:
>
> I have two questions about the metric of 'lines of code':
>
> 1. How do you actually count this? On a Unix box, I can run 'wc -l'
> to get the lines, but of course this includes comments and blank lines.
>
> 2. What is a fair number of lines of code in a one-man project that
> would show decent proficiency (i.e. for a job interview)?
> 5000? 10,000? 100,000?
>
> Thanks for any info.


The 'metric' means little. Some of my best work is 300 lines. And took
several days to write (including research, testing..). KLOC is a trap.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
 
Reply With Quote
 
Tor Iver Wilhelmsen
Guest
Posts: n/a
 
      11-30-2003
(EventHelix.com) writes:

> Another mechanism for counting lines of code is to count total number
> of semi-colons ( and closing-braces (}).


Except the empty statement is allowed as long as it's reachable.

i++;;;;;;;;;;;;;;;;;;; // KLOC-maker
 
Reply With Quote
 
John W. Krahn
Guest
Posts: n/a
 
      11-30-2003
Jeffrey Palm wrote:
>
> Digital Puer wrote:
> >
> > 1. How do you actually count this? On a Unix box, I can run 'wc -l'
> > to get the lines, but of course this includes comments and blank lines.

>
> I use this script:


Oooh! Perl code.

> my $total = 0;
> my $FORMAT = "%-40s%10d\n";
> foreach $infile (@ARGV) {
> open(infile, "<$infile") || die "Cannot open $infile:" . $!;
> my $cnt = 0;
> loop: while (<infile>) {


Perl has a special idiom 'while (<>)' that automatically opens and reads
from every file in @ARGV.

> chomp;
> s/^\s+//g;
> s/\s+$//g;


The /g option means to match "globally". In other words, to search the
entire string and find every match. However you are using the '^' and
'$' anchors which can only match at one place, the beginning and end of
the string respectively.

> foreach $a ("{","}","") {
> next loop if $_ eq $a;
> }
> my $loc = tr/;//;
> $cnt += $loc && !/^for/ ? $loc : 1;
> }
> printf $FORMAT, $infile, $cnt;
> $total += $cnt;
> close(infile);
> }
> print "-"x50 . "\n";
> printf $FORMAT, "TOTAL", $total;


This is more idiomatic Perl and is also faster in my tests.

my ( $cnt, $total );
my $FORMAT = "%-40s%10d\n";
while ( <> ) {
if ( eof ) {
printf $FORMAT, $ARGV, $cnt;
$total += $cnt;
$cnt = 0;
}
next unless /\S/;
next if /^\s*[}{]\s*$/;
my $loc = tr/;//;
$cnt += $loc && !/^\s*for/ ? $loc : 1;
}
print '-' x 50, "\n";
printf $FORMAT, 'TOTAL', $total;

__END__



John
--
use Perl;
program
fulfillment
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to know two lines are a pare parallel lines lovecreatesbeauty C Programming 11 04-28-2006 03:32 AM
How to display a string in many lines, each lines have a specified length thuyptt@dsp.com.vn C++ 1 12-06-2005 07:26 AM
Asp.Net Calender, how to display 5 lines if there are only 5 lines in one month? Jack ASP .Net 9 10-12-2005 03:44 AM
Modems, Analog Lines and ... Electrical Lines? Sens Fan Happy In Ohio Computer Support 5 09-02-2004 04:15 AM
Re: how to read 10 lines from a 200 lines file and write to a new file?? Joe Wright C Programming 0 07-27-2003 08:50 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57