31 Replies - 5011 Views - Last Post: 21 November 2012 - 12:54 PM
#16
Re: "Line Of Code" How do you define what one is?
Posted 17 November 2012 - 07:25 PM
#17
Re: "Line Of Code" How do you define what one is?
Posted 17 November 2012 - 07:47 PM

Code Metric Viewer see it as 4 lines!? What are the lines?
If we look at a AST / LISP / Scheme like view its more like.
(Where (numbers) (Lambda (x) (IF (= (% x 2) 0) (true) (false)))
Or as MSIL its a lot more.
So the relationship between Editors Lines, Logical Lines and Executable Lines and what the Debugger sees is complex to say the least.
#18
Re: "Line Of Code" How do you define what one is?
Posted 17 November 2012 - 08:31 PM
return
from x in Program.numbers()
where x % 2 == 1
select x;
Why the LINQ Query style? and not the extension method approach?
also notice its not the code I actually wrote.
#19
Re: "Line Of Code" How do you define what one is?
Posted 17 November 2012 - 10:35 PM
here is my exact definition:
a line in text ends with a new line character and or a carriage return as displayed by the text editor in question.
I don't see why it isn't just that simple.
#20
Re: "Line Of Code" How do you define what one is?
Posted 17 November 2012 - 10:49 PM
ishkabible, on 18 November 2012 - 12:35 AM, said:
It's totally arbitrary - "a line of code" is exactly what you define it to be - so it's exactly as simple or as complex as you want it to be.
If you specify the purpose you're trying to serve, that is, what sense you're trying to capture, then you can talk about what definition makes sense for that purpose, but until you do that, it's just empty noise.
#21
Re: "Line Of Code" How do you define what one is?
Posted 18 November 2012 - 12:22 AM
ishkabible, on 18 November 2012 - 06:35 AM, said:
a line in text ends with a new line character and or a carriage return as displayed by the text editor in question.
Here a couple of examples where isn't that simple.
- I refer you make to my 43 IDE line C# example.
- XML Literals in vb.net follow the grammar rules of XML, thus has significant whitespace. So replacing newlines with spaces would change the meaning of the code.
Same for - VB.net's Implicit Line-Continuations
- Verbatim String Literals in Nemerle
def s10 = @"""Nemerle"" // comment rocks !";
If you which is three lines of text, so if replace the newlines with spaces. It would highly not compile since the final " would inside the comments.
"Nemerle" rocks !
What about language called Piet?
This post has been edited by AdamSpeight2008: 18 November 2012 - 12:35 AM
#22
Re: "Line Of Code" How do you define what one is?
Posted 18 November 2012 - 12:42 AM
AdamSpeight2008, on 18 November 2012 - 08:22 AM, said:
Yes, it is that simple. It seems to me that you're basically saying "The term 'lines of code' can't refer to actual lines because then it would be a completely meaningless measure of any interesting property of the code". But that's not a contradiction. It is a completely meaningless measure of any interesting property of the code.
Quote
Clearly talking about lines of code in a Piet program is even more meaningless than it is for regular programs.
#23
Re: "Line Of Code" How do you define what one is?
Posted 18 November 2012 - 12:53 AM
Is a commented out "line of code" a "line of code"?
Isthere a universal definition of "line of code" that apply to all programming languages?
This post has been edited by AdamSpeight2008: 18 November 2012 - 12:58 AM
#24
Re: "Line Of Code" How do you define what one is?
Posted 18 November 2012 - 12:58 AM
Quote
None, because ice cream has no bones.
This post has been edited by jon.kiparsky: 18 November 2012 - 01:00 AM
#25
Re: "Line Of Code" How do you define what one is?
Posted 18 November 2012 - 01:12 AM
"I inherieted 20K lines of spagethi code"
"My project has X lines of Code"
Linux written in 176,250 Lines of code.
Windows XP written in 40 million lines of code.
How many of those do actual work?
Does more or less lines indicates better coding?
What is the perfect ratio? non executing / executable lines
#26
Re: "Line Of Code" How do you define what one is?
Posted 18 November 2012 - 01:25 AM
AdamSpeight2008, on 18 November 2012 - 09:12 AM, said:
Because it's easily measurable and people like numbers. It is a mistake to assume that because a lot of people talk about something, it must actually be meaningful.
Note that if we defined "lines of code" to mean anything other than actual lines, it would no longer be easily measurable. It stands to reason that when someone says "I inherieted 20K lines of spagethi code" he did not in fact count the "logical lines of execution" in the code (because that would have taken a while and no one's that bored), so he can only be talking about the actual lines in the file (which can be easily found out by running wc -l on the code base or using equivalent functionality of your text editor or IDE).
AdamSpeight2008, on 18 November 2012 - 08:53 AM, said:
I know and I certainly didn't mean to imply anything to the contrary (and I don't think I did). When I said "it is that simple" I meant that ishkabible's definition is in fact a reasonable one.
This post has been edited by sepp2k: 18 November 2012 - 01:25 AM
#27
Re: "Line Of Code" How do you define what one is?
Posted 18 November 2012 - 01:35 AM
Quote
No. Assuming it meets requirements, code is good to the extent that it is clear and can be maintained by some programmer who has never met the original programmer but is reasonably familiar with the language. That's all. If this is achieved by adding lines, add lines. If it is achieved by removing lines, then lines must be removed.
Last week, I removed approximately 500 lines of gratuitous whitespace from a blob of PHP and javascript that's going to be deployed one day, prepatory to refactorings which will probably remove a similar number of lines. However, the important thing about this operation is that cleaning up the style so that the repeated lines would stand out, and can be extracted easily. The refactorings I'll be doing next week are about simplifiyng the code - since this will eliminate repetition, it will shorten it, but it's about simplicity, not concision.
If this had been written by someone else, and they'd rammed a bunch of chained functions together on one line to save vertical space, or otherwise compressed the code at the expense of the reader, the code would have gotten longer instead of shorter. Length is not interesting, unless it serves a purpose. A function should fit on one screen, as a rule, and it's
Again: more clarity, not fewer lines.
Any other rule serves some purpose other than making good and durable code.
#29
Re: "Line Of Code" How do you define what one is?
Posted 20 November 2012 - 02:23 AM
Is there an equation that produce say a clarity score? Where a score of zero in the is no "clarity" Isn't that intangible and subject to whim and fancy?
#30
Re: "Line Of Code" How do you define what one is?
Posted 20 November 2012 - 04:32 AM
Although it is difficult to measure, the book Clean Code provides a set of guidelines to help write clean code. It has helped me enormously.
|
|

New Topic/Question
Reply




MultiQuote







|