Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count lines of code

Status
Not open for further replies.

TysonLPrice

Programmer
Jan 8, 2003
859
US
Does anyone know of a way to count the lines of code in Views, Functions, and SPs in a database? I did our VB 6.0 projects and was able to skip comments and blank lines.

Before anyone asks why :)

It came down from coporate…
 
Don't forget to count your lines in triggers too.

There may be a commercial (or even freeware) application that can do this, but it's probably going to be a little weird. Think about it this way.... what counts as a line? This?

[tt][blue]
Select col1, col2, col3 from tablename where id = 7
[/blue][/tt]

[tt][blue]
Select
Col1
,
Col2
,
Col3
From
TableName
Where
ID
=
7
[/blue][/tt]

Both would be valid queries. I doubt anyone would format their query using the 2nd method I show, but it is possible and it does work. So, a simple query like I show above could be 1 line or 12. That's a big difference.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Hmm. you can try using MS Word. Copy all your code into a word document. Remove all your comments, etc. that you do not want. Then, under Tools, click Word Count. The last entry is Line COunt (Word 2003).
 
I punched them into text files and looped through them with a quick and dirty VB project. gmmastros made a good point about formatting. At least I could exclude blank lines. Out of 10,675 SPs I counted 441,273 lines of code.
 
In the PBS documentary Triumph of the Nerds, Microsoft executive Steve Ballmer criticized the use of counting lines of code:

In IBM there's a religion in software that says you have to count K-LOCs, and a K-LOC is a thousand line of code. How big a project is it? Oh, it's sort of a 10K-LOC project. This is a 20K-LOCer. And this is 50K-LOCs. And IBM wanted to sort of make it the religion about how we got paid. How much money we made off OS/2, how much they did. How many K-LOCs did you do? And we kept trying to convince them - hey, if we have - a developer's got a good idea and he can get something done in 4K-LOCs instead of 20K-LOCs, should we make less money? Because he's made something smaller and faster, less K-LOC. K-LOCs, K-LOCs, that's the methodology. Ugh! Anyway, that always makes my back just crinkle up at the thought of the whole thing.

I know it's corperate but just a thought...

Simi
 
back in my time also with IBM on the middle one of our teams made a set of sub routines that got called from almost every program that team developed.

Whenever they counted the number of lines of a new program using those sub-routines they would add the number of lines of those to the main program. their team always had the biggest LOC count.



Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top