4 ms·
I don't see how "logical lines", whatever that is At least by the definition I'm accustomed with, a logical line is a statement or series of statements which d
by slowpoke 15y ago
I don't see how "logical lines", whatever that is
At least by the definition I'm accustomed with, a logical line is a statement or series of statements which directly and logically belong together, for example a function call or an arithmetic operation.
Logical lines are independent from physical lines as each logical line can be split over multiple physical lines (eg splitting up a long string IO operation), or one physical line can contain multiple logical lines (this is a bad idea in most cases though).
Since the definition hinges a bit on what somebody considers as "logically belonging together", the whole concept is a bit fuzzy. Consider this string formatting operation (Python):
somestring.split(somechar)[-1]).replace("foo", "bar")
Do you consider this one logical line? Or would your logical lines look more like this:
somestring = somestring.split(somechar)
somestring = somestring[-1]
somestring = somestring.replace("foo", "bar")
Both are valid interpretations of logical lines, but they are visually and conceptually quite different, which makes it - imho - a bit problematic to try and use them as a measure of code quality.
- gruseom 15y agoYou make sense, but the concept itself seems so fuzzy and hard to nail down that I marvel at how it ever arose, given that there already exists an unambiguous and ubiquitous way to distill the logical structure of code free of textual artifacts.
- akkartik 15y agoI think token count hasn't gained traction because of languages with syntax and types. "Surely all the boilerplate in defining a class doesn't make it more complex," goes the argument. I prefer to turn the debate around on its head. Rather than argue complexity metrics (boring) I say I prefer languages without boilerplate because they make complexity harder to camouflage.
- gruseom 15y agoOne can argue that boilerplate doesn't add to complexity (though I don't agree). But no one can argue that it doesn't add to code size. The studies cited in this thread show either linear or superlinear growth of bug count with code size. If those studies are correct, doesn't that rather settle the issue?
- akkartik 15y agoYep.