Lines of code
-
There are plenty of free VS add ins that generate that number for you.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
You could always write a utility to count semi-colons in all files in a directory to give you a rough estimate.
int x ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
x = 42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -
int x ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
x = 42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;it is still 42 :^)
Yusuf May I help you?
-
int x ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
x = 42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;I would say semicolon counting is still more accurate for counting lines of code than line endings. And like others have said, counting the number of lines is no measure of quality (the above code being of crap quality, but a large number of lines). Or the two method could be combined into something like this:
int numberOfLines = Regex.Matches(@"\;( |\t)*(\r|\n|\\\\|\\\*)", fileText).Count;
But then some trickster could get you with this:
public void DoIt()
{
int x
= 5; int
y = 10;}However, if the guy just wants to tell his friend how much code he wrote, this method (or similar approximations) should work fine.
Visual Studio is an excellent GUIIDE.
-
I would say semicolon counting is still more accurate for counting lines of code than line endings. And like others have said, counting the number of lines is no measure of quality (the above code being of crap quality, but a large number of lines). Or the two method could be combined into something like this:
int numberOfLines = Regex.Matches(@"\;( |\t)*(\r|\n|\\\\|\\\*)", fileText).Count;
But then some trickster could get you with this:
public void DoIt()
{
int x
= 5; int
y = 10;}However, if the guy just wants to tell his friend how much code he wrote, this method (or similar approximations) should work fine.
Visual Studio is an excellent GUIIDE.
Does that handle
for
loops?for
(
int i = 0 ;
i < 10 ;
i++
)
{
...
} -
A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?
bart
Run a metrics calcuation tool before you write a single line of code. Whenever you generate code automagically using some tool, run it again before and after. Calculate your averages, it's not that hard. Google SLOCCount it's a linux tool that calculates SLOC for many languages, I use t all the time :) Cheers, Alex
-
A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?
bart
Just reply "I wrote all the good ones, and tool who sits by the window wrote the rest".
I wanna be a eunuchs developer! Pass me a bread knife!
-
I don't know; I also don't care. "Lines of code" is a meaningless statistic, and has been since Cobol and Fortran stopped being the standard languages. Is a line with just an "{" or "}" a "line of code"? Or is
MySqlCommand cmd = new MySqlCommand("UPDATE " + TableNames.my\_RoleAndPerformance.ToString() + " SET role=@R, dateNextChangeRole=@NCR, data=@D, ValidationCode=@VC" + " WHERE UserId = @ID"); cmd.Parameters.AddWithValue("@R", role); cmd.Parameters.AddWithValue("@NCR", dateNextChange); cmd.Parameters.AddWithValue("@D", data); cmd.Parameters.AddWithValue("@VC", validationCode); cmd.Parameters.AddWithValue("@ID", userId);
One "line of code", since it will not work without the entire sequence? Forget "lines of code", think "functional blocks", think "tested and peer reviewed", think deadlines, bug count, any performance measure that actually means something!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?
bart
As I program in C++ generally, I'll just use this command at the root of my source tree:
ack --cpp -c ; | wc -l
This counts all semi-colons, which is a reasonable approximation for the total lines in the project. I never differentiate between auto-generated/me-generated lines.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?
bart
>>> how many were generated by a tool? For some of the people I work with, this is 100%!
==================================== Transvestites - Roberts in Disguise! ====================================
-
283,000 at the last formal build. I know because we track a variety of project metrics on each build using the (free) SourceMonitor[^] tool. I'm more interested in average cyclomatic complexity has gone down (which is good as it means that the code is getting less crufty) or up (which implies that some of the changes in the build are more complex than they need to be) rather than LOC, but we get that as well.
Anna :rose: Having a bad bug day? Tech Blog | Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"
-
I would say semicolon counting is still more accurate for counting lines of code than line endings. And like others have said, counting the number of lines is no measure of quality (the above code being of crap quality, but a large number of lines). Or the two method could be combined into something like this:
int numberOfLines = Regex.Matches(@"\;( |\t)*(\r|\n|\\\\|\\\*)", fileText).Count;
But then some trickster could get you with this:
public void DoIt()
{
int x
= 5; int
y = 10;}However, if the guy just wants to tell his friend how much code he wrote, this method (or similar approximations) should work fine.
Visual Studio is an excellent GUIIDE.
Oh, and semi-colons in verbatim strings:
string sql =
@"
SELECT COUNT(*) FROM table1 ;
SELECT COUNT(*) FROM table2
" ;