Code lines number influenced by formatting style.

Started by
22 comments, last by Bacterius 10 years, 1 month ago


How do developers deal with this issue? It can be the difference between 120,000 lines of code and 40,000 lines of code.

I guess that if you want to trick your boss, then the former is recommended.

Why would you trick your boss?

Do you really think any of us get paid per line of code?

The simple answer is that it is a non issue. The number of lines of code in a project doesn't really matter. Somedays I delete more lines of code than I add to a project.

Advertisement

I often delete code. Do[es] you really believe some boss might see me deleting code, and think of it as negative progress?

Yes. Sorry for applying stereotypes to managers, but they tend to have no clue of what is going on in the code(unless they are technical directors.), they also tend to be cynical, so it wouldn't surprise me that they complain for anything that one does. This includes breathing in a different rhythm than his.

How do you think programming progress is measured?

How do you think the intelligence of a person is measured?
By reading or listening to the arguments they create, and extracting the level of comprehension skills, among other tests.

Why do you assume that I have no idea how the application's programming progress is measured?
Perhaps you do not comprehend the semantic of the original post.

Why would you trick your boss?

Do you really think any of us get paid per line of code?

That's a straw-man argument.
It is implicit in the original post that perhaps it shouldn't be so(that lines of could should ever matter.)

You are opposing an argument that I never made, and if any(implicit) it was the opposite of what you report.

Intel Core 2 Quad CPU Q6600, 2.4 GHz. 3GB RAM. ATI Radeon HD 3400.

It is implicit in the original post that perhaps it shouldn't be so(that lines of could should ever matter.)

No it isn't.


You are opposing an argument that I never made, and if any(implicit) it was the opposite of what you report.

I'm not opposing anything. Those strange symbols at the end of my sentences are question marks.

The imprecision of a line count is highly influenced by code formatting style:


int
function(int a, int b, int c)
{
    // Burn the  Parthenon here.
    int culprit;
   
}
 
for(unsigned i=0; i<n; i++)
{
    // Clean your room here.
}

As opposed to:


int function(int a, int b, int c){
    int culprit; // Burn the  Parthenon here.}
for(unsigned i=0; i<n; i++){
    // Clean your room here.}

How do developers deal with this issue? It can be the difference between 120,000 lines of code and 40,000 lines of code.

I guess that if you want to trick your boss, then the former is recommended.

There several programs available for counting lines of code and stripping comments is typically an option. E.g. see cloc. I don't know if brace style is taken into account, but as Frob said, any value gained from lines-of-code metrics tends to be from an order of magnitude point of view.

-Josh

--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet

Just to mention: If one wants to use SLOCs as a measure for programmer activity (and I do not recommend so), then comments should IMHO be included. Comments are an important part, and commenting definitely costs time.

Just to mention: If one wants to use SLOCs as a measure for programmer activity (and I do not recommend so), then comments should IMHO be included. Comments are an important part, and commenting definitely costs time.

Lines of code deleted per day should also be counted. Often, a negative LOC/day metric is more productive / adds more value than a positive one wink.png

imo code-lines counting is quite usable (even more yet more strange 'metrics' (like code section length) are usable imo - I would even get this

line counting per day, built-in in my ide


If you get paid by the number of lines created, or if your boss even cares about this as some kind of metric, it's time to switch job.

Or write the most inefficient, crappy code imaginable. Unroll your for-loops, replace arrays with variables having actual numbers in their names, and obviously add "hacker protection code" to impress your boss - that's far more enterprisey.

You'll become the top programmer in no time.

(warning: post contains severe sarcasm)

"I would try to find halo source code by bungie best fps engine ever created, u see why call of duty loses speed due to its detail." -- GettingNifty

If you want to measure your code more accurately, SourceMonitor is pretty cool. It measures the statements, and the average number of statements per function (to encourage keeping functions smaller), and the average number of nested scopes per function, the average number of functions per class, and other useful things.

This still doesn't measure the value of each line of code, so it is still a useless measurement for programmer work performance, but it does help measure function complexity (but not architectural complexity).

Not only do most programmers not care about LOC, _smaller_ LOC is often considered better. _Not_ via formatting tricks or writing overly terse lines but because better programmers tend to not need to make 50 classes spread over 30 files to implement your common feature. I'd rather pay a guy who knows how to write 3 lines of Python to automate a task than someone who insists on using C++ to write a massively over-engineered behemoth of a program to do the same thing (with more bugs), for instance.

Most programmers don't care about LOC, period. In the game industry especially, we don't tend to have pointy-haired middle managers that look at irrelevant metrics like LOC (though sometimes we have pointy-haired managers looking at _other_ irrelevant metrics, like number of bugs closed). My experiences have been that most of the people managing engineers in the gaming industry are either highly technically-knowledgeable leads (who know better than to measure LOC) or producers (who couldn't give a rats ass about the code beyond whether it does what it needs to or not).

So far as programmers playing tricks to change LOC, I'd reprimand any programmer wasting company time (and hence money) on actively degrading the quality of the code. Consistency matters 10x more than almost anything else in large projects; follow the official project style, even if you feel it's a non-optimal one. If the company doesn't have any standards, start advocating that it adopts some. Checkins with most SCMs can even be set up with certain tools to warn (or even outright fail) on code that doesn't follow standards.

Sean Middleditch – Game Systems Engineer – Join my team!

This topic is closed to new replies.

Advertisement