Advertisement Jump to content
Sign in to follow this  
gasto

Code lines number influenced by formatting style.

This topic is 1777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Edited by gasto

Share this post


Link to post
Share on other sites
Advertisement
I prefer the former but mine is :
#include <iostream>
#include <string>

using namespace std;

int triple (int num)
{
for (num = 0; num < 12; num += 2)
{
cout << num;
}

return num;
}

int main ()
{
string name;
int digit = 0;

cout << "Enter your name: ";
getline (cin, name);

cout << "Welcome " << name << endl;

triple (digit);

return 0;
}
I really love spaces because it makes my code clearer.
Depending on the programmer, a program can be 1000,000 lines of code or 100,000 lines of code.

Share this post


Link to post
Share on other sites

Don't count empty lines, bracer-only lines, comments, or even code that only contains declarations such as variables or function prototypes. And since you can split expressions over multiple lines, count multi-line statements as one. The options are near endless if you use a syntax-sensitive line counter.

Share this post


Link to post
Share on other sites

I mention it because some programmer blogs insinuate in their posts that it matters. It is common to read:

"My project which is a 70,000 lines of code, was finished in 2007."

 

"... we were dealing with a huge codebase of 5,000,000 lines of code..."

However according to a study that I heard from Arthur Griffith, it takes roughly the same amount of time to write the same amount of lines of code in different languages by the same programmer. How true that is unverifiable for now(I can't find the study.)

Edited by gasto

Share this post


Link to post
Share on other sites

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


By not caring.

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


My boss doesn't look at code, and if he did, I doubt he'd be counting lines.

I often delete code. Does you really believe some boss might see me deleting code, and think of it as negative progress? How do you think programming progress is measured?

Share this post


Link to post
Share on other sites

A more effective way to compare lines of code in a C like language is grep for semicolons.

 

But really, it doesn't matter, it's a very cude measure anyway.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!