Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, alibaba, Quad), 761 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 4 1 2 3 4
Re: How many Lines? [Re: Puppeteer] #302421
12/19/09 11:52
12/19/09 11:52
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
hats off!
that's a lot of code in less than 2 months....


~"I never let school interfere with my education"~
-Mark Twain
Re: How many Lines? [Re: Germanunkol] #302423
12/19/09 12:34
12/19/09 12:34
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
Some friends of mine coded Tetris in our school's Delphi course. It worked, and when we all had to present our projects in the end everyone was stunned by them, because they scrolled through one huge file showing some thousand lines of code. What they actually did was draw every Tetris block in every orientation in its own function and for every keystroke and every block and (!) every orientation they had a separate function checking the block against the level. This was so plain stupid I hardly fell of my chair when they showed me the code.

I want to cite Steve Ballmer:
Originally Posted By: Steve Ballmer
In IBM there's a religion in software that says you have to count K-LOCs, and a K-LOC is a thousand line of code. How big a project is it? Oh, it's sort of a 10K-LOC project. This is a 20K-LOCer. And this is 50K-LOCs. And IBM wanted to sort of make it the religion about how we got paid. How much money we made off OS/2, how much they did. How many K-LOCs did you do? And we kept trying to convince them - hey, if we have - a developer's got a good idea and he can get something done in 4K-LOCs instead of 20K-LOCs, should we make less money? Because he's made something smaller and faster, less K-LOC. K-LOCs, K-LOCs, that's the methodology. Ugh! Anyway, that always makes my back just crinkle up at the thought of the whole thing.


Honestly, SLOCs is just not the way to compare source code. I know that you all might think size matters, but it just makes my head ache when I read something like this:

Originally Posted By: Germanunkol
But I've written all this code more than once, from scratch, cause it used to be WDL and I ported it... so can I count it twice?


If I was interviewing someone for a job and he told me something like that he'd not get the job.

What I do find interesting, though, is in how much source files you separate your code.

Re: How many Lines? [Re: Joey] #302426
12/19/09 13:06
12/19/09 13:06
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Just to "defend" myself (and get the fictional job): my sarcasm got lost on that sentence you quoted, sorry about that.

I asked only for number-of-lines in this topic because I was interested in getting an idea of how many lines others write, not because I was going to say "you have more lines you're better" or "you have less lines you're better". As I have no idea what all the lines of code do, that other people posted, I am never going to compare the projects in this way.

I thought it interesting to see that people keep going, even though a lot of this is non-payed, and was happy to see that some of this non-payed work is so large.
Big amounts of code means lots of work, which I was interested in. I never said that small amounts of code means less work, and never intended to say so. Personally, I am very fond of every function that does the same thing, more efficiently, with less code. Even if the code's harder to read, i always loved trying to interpret and understand "dense" code.

Sorry, I did not want to make your head ache.

Last edited by Germanunkol; 12/19/09 13:09.

~"I never let school interfere with my education"~
-Mark Twain
Re: How many Lines? [Re: Germanunkol] #302432
12/19/09 14:11
12/19/09 14:11
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline
Serious User
LarryLaffer  Offline
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
I think you'll have to find your balance between ease of reading and saving resources, and stick to it while writing your whole project. Sometimes, saving 8 bytes of ram, or getting away with 2 less lines of code is not worth the effort if it will make my code less readable, so I'll go for the simpler way. For example, I might have done that on a Commodore where ram is precious:

Code:
//Switch two variables
a+=b;
b=a-b;
a-=b;



But with a Pentium Duo with 4 gigs of ram, i'd use a third variable, thank you very much...

Code:
//Switch two variables
c=a;
a=b;
b=c;



Sometimes, it may be hard to resist using all these new sophisticated algorithms you've learned, making your code as tight as possible, but sometimes you'll also have to consider other people reviewing your code, or even yourself in 5 years. In big companies, your code will go through at least 1 or 2 more pair of eyes that their job is to 'clean up' your code and nothing angers them more than trying to decipher recursion functions when a single loop would have sufficed. Imo, I don't blame them..

Ps: I'm not referring to anyone in particular, just tossing my two cents..


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: How many Lines? [Re: LarryLaffer] #302439
12/19/09 14:56
12/19/09 14:56
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
Yes, but writing efficient code and writing readable code don't need to be two different things.

Re: How many Lines? [Re: Joey] #302454
12/19/09 16:49
12/19/09 16:49
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline
Serious User
LarryLaffer  Offline
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
Well, how about my example above.. Both three lines of code. First one uses less memory while the second one is easier to follow. Both come out with the exact same result.. I come up with things like that all the time, and I do find myself having to choose between code efficiency and readable code.


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: How many Lines? [Re: LarryLaffer] #302456
12/19/09 16:52
12/19/09 16:52
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
Originally Posted By: LarryLaffer

Code:
//Switch two variables
a+=b;
b=a-b;
a-=b;




wow, that just blew my mind grin i'd never have thought of that.

Re: How many Lines? [Re: lostclimate] #302460
12/19/09 17:22
12/19/09 17:22
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
but that's dangerous practise, because like that a could overflow and produce unwanted results. and i'm not speaking of three lines but of people who can't code and produce extremely huge SLOCerz.

by the way, this one works without overflow (and might even be faster):

Code:
a ^= b;
b ^= a;
a ^= b;



so why not just create an inline function or a macro performing this task? if you need it often, this would make your code look more readable than by using a temporary variable.

Re: How many Lines? [Re: lostclimate] #302462
12/19/09 17:37
12/19/09 17:37
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
7731 lines in 63 files, but this isn't a gamestudio project.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: How many Lines? [Re: Joey] #302467
12/19/09 18:11
12/19/09 18:11
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline
Serious User
LarryLaffer  Offline
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
Oh yes, I'm with you, I hate it when people rate your work based on your lines of code. I read somewhere about a university project in delphi where they had to make an ascii tetris game. One group actually made a function for each different tile like that:

draw(" * ");
draw("***");

etc, and even individual draw functions for each rotation of the tile, and even further separate functions testing collision for each of the tile and rotation functions tongue. Should this guy really get paid more than someone that took the extra five minutes to combine all this into one function using 10 lines?

I'm just expressing some frustration over people obsessed with too dense code, just so they can save one or two lines. I believe there's a balance you'll have to find that will work for you, and hopefully for others reading that code as well.

Let me give you another example. I see a lot of people use bitwise expressions so that they can use single-byte variables (f.e. a char) to store information for 8 different flags (true or false booleans). I'd rather use an array of 8 booleans to do this, to make the code more readable, even if C's booleans take 8 bits each. But that's just me..


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Page 2 of 4 1 2 3 4

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1