"Line Of Code" How do you define what one is?

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

31 Replies - 6420 Views - Last Post: 21 November 2012 - 12:54 PM

#1 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2262
  • View blog
  • Posts: 9,462
  • Joined: 29-May 08

"Line Of Code" How do you define what one is?

Post icon  Posted 16 November 2012 - 03:28 PM

How do you define what constitutes a line of code?

  • Is it number of line it takes in the IDE or editor?
  • What about line continuations (implicit and explicit).
  • Do comments count?
  • Is it the number of end of statement markers? eg. ; in C style languages.
  • Is it the number of statements?
    • What is a statement?
    • What is a expression?
    • What about multiline Lambdas?
    • Is method-call-chaining 1 LoC or higher?
  • Is it number of lines it gets compiled to?


Is This A Good Question/Topic? 1
  • +

Replies To: "Line Of Code" How do you define what one is?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9192
  • View blog
  • Posts: 34,509
  • Joined: 12-June 08

Re: "Line Of Code" How do you define what one is?

Posted 16 November 2012 - 03:36 PM

It depends what is at stake? Is it an ePenis "efficiency" contest where I win all the feels? Then roughly 30-45% less than what is displayed in the IDE.

If it is to complain about a'boot my work then it's 43-57% more than current IDE line reporting.

In general the IDE's clean up keycommands provide me a decent approximation on how many lines. Of course I don't comment my code so no need to fear about that mucking up the number.
Was This Post Helpful? 1
  • +
  • -

#3 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7737
  • View blog
  • Posts: 13,068
  • Joined: 19-March 11

Re: "Line Of Code" How do you define what one is?

Posted 16 November 2012 - 04:00 PM

Since there's nothing interesting about code that's measured in lines, it seems a bit pointless to worry about what a line might be.
Was This Post Helpful? 2
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2262
  • View blog
  • Posts: 9,462
  • Joined: 29-May 08

Re: "Line Of Code" How do you define what one is?

Posted 16 November 2012 - 04:02 PM

Is the follow 12 LoC (IDE lines)
or 2 LoC ( the lambda is considered a part of line)
or 4 LoC (Using ; statement terminators )?
or 5 LoC (Same as above but includes the if statment)

      var numbers = Enumerable.Range(1, 100);
      var odds = numbers.Where(x => {
                                      if (x % 2 == 1)
                                      {
                                        return true;
                                      }
                                      else
                                      {
                                        return false;
                                      }
                                    }
                               );



If not LoC? then what?

This post has been edited by AdamSpeight2008: 16 November 2012 - 04:03 PM

Was This Post Helpful? 0
  • +
  • -

#5 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1989
  • View blog
  • Posts: 4,124
  • Joined: 11-December 07

Re: "Line Of Code" How do you define what one is?

Posted 16 November 2012 - 06:16 PM

If I ask you to look at line 12 of that code you will know exactly what I mean. How can anyone reasonable argue that it is anything other than 12 lines?
Was This Post Helpful? 4
  • +
  • -

#6 aresh  Icon User is offline

  • It's a 16-Bit World!
  • member icon

Reputation: 273
  • View blog
  • Posts: 4,164
  • Joined: 08-January 12

Re: "Line Of Code" How do you define what one is?

Posted 17 November 2012 - 03:03 AM

Well, I totally agree with modi :)
Was This Post Helpful? 0
  • +
  • -

#7 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: "Line Of Code" How do you define what one is?

Posted 17 November 2012 - 10:59 AM

View Postcfoley, on 17 November 2012 - 01:16 AM, said:

If I ask you to look at line 12 of that code you will know exactly what I mean. How can anyone reasonable argue that it is anything other than 12 lines?


agreed.

adam: stop confusing lines with language constructs like expressions and statements ;)
Was This Post Helpful? 2
  • +
  • -

#8 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4333
  • View blog
  • Posts: 12,128
  • Joined: 18-April 07

Re: "Line Of Code" How do you define what one is?

Posted 17 November 2012 - 12:52 PM

As Jon had already said, LoC are pretty useless as a measurement of anything. I think we all know that we can easily take 10 lines and chain them together into one and what does that really say about anything?

I personally think of things in complete lines of thought. Where your lambda would be one line because all that conditional stuff is just to specify conditions for the where(). But if someone asked me how many lines of code I wrote today I would turn to them and ask "Why would that matter?" The ultimate goal is to solve problems, not and try to verify my performance by measuring how many lines I can pump out in X minutes/hours.

In short, ishkabible said it best, stop confusing lines with constructs. But to add to that, stop fussing about lines of code meaning anything.

:)
Was This Post Helpful? 3
  • +
  • -

#9 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2262
  • View blog
  • Posts: 9,462
  • Joined: 29-May 08

Re: "Line Of Code" How do you define what one is?

Posted 17 November 2012 - 03:34 PM

Why you lot assuming that I don't know the difference? between an expression and a statement? What happen to discussion?

View Postcfoley, on 17 November 2012 - 02:16 AM, said:

How can anyone reasonable argue that it is anything other than 12 lines?

So you are say its 12 Editor lines of code. Is it that simple?
The 12 Lines are an arbitrary stylistic choice.
This is valid C# and functionally the same.
Spoiler

or 5 LoC
Spoiler

or as non of you "so called programmers" not pointed out.
Spoiler




I thing can conclude is you lot are paid in terms of the number of lines of codes, and that ishkabible and jon.kiparsky still having an hissy fit at getting FizzBuzz wrong?

This post has been edited by AdamSpeight2008: 17 November 2012 - 03:35 PM

Was This Post Helpful? 0
  • +
  • -

#10 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1989
  • View blog
  • Posts: 4,124
  • Joined: 11-December 07

Re: "Line Of Code" How do you define what one is?

Posted 17 November 2012 - 03:50 PM

No offence was meant. Sorry if some was taken. I've never been paid by lines of code. In fact I've never calculated lines of code for any of my paid projects.

I see that c# code as 46 lines, all of them terrible. The last example is a lot better quality.

I actually typed a post about refactoring your original code but decided it was off topic. Your code was obviously crafted to make a point, not to stand as an example of good programming.
Was This Post Helpful? 2
  • +
  • -

#11 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7737
  • View blog
  • Posts: 13,068
  • Joined: 19-March 11

Re: "Line Of Code" How do you define what one is?

Posted 17 November 2012 - 04:01 PM

I can't say that anyone has brought up the idea of lines of code in my presence in my professional life, to be honest. But then, you're the one who brought up the issue, twice in one day. Why? What's interesting about whether
for 
(
int 
i
= 
i
; 

....


is one line or some or many? What's at stake here, for you? How can this possibly matter to anyone?

(as for your efforts to bait me into some sort of squabble - it's not going to work, so come off it and quit acting like a child)
Was This Post Helpful? 1
  • +
  • -

#12 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2262
  • View blog
  • Posts: 9,462
  • Joined: 29-May 08

Re: "Line Of Code" How do you define what one is?

Posted 17 November 2012 - 05:39 PM

jon.kiparsky What is your vested interest in not have a discussion about it?


Code Golf challenges tends just the metric of minimum number of non-white-space characters wins. So is using the programming language WhiteSpace cheating? (Since the count will always be Zero.) What about significant whitespace? are they also excluded also? They are required to make the program syntactically correct, in for example languages like Haskell and Python.

Since LISP is homoiconic, so is right to say all LISP program are a single S-Expression?

This post has been edited by AdamSpeight2008: 17 November 2012 - 05:52 PM

Was This Post Helpful? 0
  • +
  • -

#13 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2262
  • View blog
  • Posts: 9,462
  • Joined: 29-May 08

Re: "Line Of Code" How do you define what one is?

Posted 17 November 2012 - 06:20 PM

Quite interesting to note that setting a Breakpoint on IDE Line 11, highlights 12 lines.
Attached Image

and where you are allowed to set breakpoint in that example.
(IDE Lines 23 onwards.)

You can't set one mid-expression, but can set one on the beginning of the lambda body.

This post has been edited by AdamSpeight2008: 17 November 2012 - 06:25 PM

Was This Post Helpful? 0
  • +
  • -

#14 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1989
  • View blog
  • Posts: 4,124
  • Joined: 11-December 07

Re: "Line Of Code" How do you define what one is?

Posted 17 November 2012 - 06:37 PM

Is that because breakpoints have little to do with lines?

You can write an s expression on one line or several.

Python and Haskell are pretty cool. I wish more languages has sensible whitespace rules rather than conventions.
Was This Post Helpful? 0
  • +
  • -

#15 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2262
  • View blog
  • Posts: 9,462
  • Joined: 29-May 08

Re: "Line Of Code" How do you define what one is?

Posted 17 November 2012 - 07:16 PM

Setting a breakpoint on IDE line 23 highlights a lot of editor lines including the lambda. So could it indicate you can only set breakpoints at the start of a logical line of execution.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3