• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
gasto

Code lines number influenced by formatting style.

23 posts in this topic

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
0

Share this post


Link to post
Share on other sites
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.
-2

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.

0

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 [url=https://www.odesk.com/o/profiles/users/_~012285c45d9a4e16a8/]Arthur Griffith[/url], 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
0

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?
1

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.

0

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.

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.

0

Share this post


Link to post
Share on other sites

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.

Edited by gasto
0

Share this post


Link to post
Share on other sites

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.

Edited by Buster2000
0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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.

2

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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)

Edited by TheComet
2

Share this post


Link to post
Share on other sites

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).

1

Share this post


Link to post
Share on other sites
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.
2

Share this post


Link to post
Share on other sites


replace arrays with variables having actual numbers in their names

 

Array length known only at runtime? Only one reasonable solution - self-modifying code, and invoking undefined behaviour by assuming the variables are placed contiguously on the stack. Actually, scratch that - lookup is achieved by a sufficiently large switch.. no, that's too readable.. a long list of if/else conditions.. no.. you know what, let's just precompute the program's output for every possible input and just hardcode that. It was throwaway code anyway.

0

Share this post


Link to post
Share on other sites
LOC isn't a totally useless metric. It can be used a a proxy for how long it would take to find a bug, and the over all complexity of a project. It's just important to remember that it's not an accurate measure. But sometimes, that's ok.
1

Share this post


Link to post
Share on other sites


let's just precompute the program's output for every possible input and just hardcode that. It was throwaway code anyway.

Maximum productivity according to LOC goes to this man!

0

Share this post


Link to post
Share on other sites


Maximum productivity according to LOC goes to this man!

 

Uncountably many lines, for almost all programs cool.png

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0