Linked by Thom Holwerda on Fri 15th Feb 2013 10:40 UTC
General Development "Since I left my job at Amazon I have spent a lot of time reading great source code. Having exhausted the insanely good idSoftware pool, the next thing to read was one of the greatest game of all time: Duke Nukem 3D and the engine powering it named 'Build'. It turned out to be a difficult experience: The engine delivered great value and ranked high in terms of speed, stability and memory consumption but my enthousiasm met a source code controversial in terms of organization, best practices and comments/documentation. This reading session taught me a lot about code legacy and what helps a software live long." Hail to the king, baby.
Thread beginning with comment 552605
To read all comments associated with this story, please click here.
Code Review
by Alfman on Fri 15th Feb 2013 13:14 UTC
Alfman
Member since:
2011-01-28

"Note : If a file/variable name features a number: it is probably not a good name !"

Says who? Variables have used numbers for subscripts for as long as I can remember. Coordinates are aptly named x1,y1,z1, x2,y2,z2 ... Given their frequency in a graphics codebase I think it's far better than the alternatives I can think of.


Anyways articles like this always spike my interest, would have like more technical depth, but still neat to read about it.

If anyone were to ever review my code from 15 years ago, I'm sure that I'd get a lot of flak ;) Anyone heard of Advo Sched? No...oh well.

Reply Score: 3

RE: Code Review
by Laurence on Fri 15th Feb 2013 13:57 in reply to "Code Review"
Laurence Member since:
2007-03-26

I have a love/hate relationship with articles like these.

On the one hand it's great to promote readable code, but sometimes I think people get too hung up on what they deem as perfect syntax and can sometimes miss the point of those clever optimisations.

It's a bit like grammar Nazi's who love to correct peoples comments but rarely read deep enough into those posts digest the content being explained.

So I guess what I'm trying to say is that it's good to be reminded about preferred programming practices, just as long as we don't forget the other criteria (usability, performance (if applicable), deadlines)

Edited 2013-02-15 13:59 UTC

Reply Parent Score: 11

RE[2]: Code Review
by moondevil on Fri 15th Feb 2013 13:59 in reply to "RE: Code Review"
moondevil Member since:
2005-07-08

After a few sessions of off-shore code review, one really stops caring about code quality as long as what was requested works.

Reply Parent Score: 3

RE[2]: Code Review
by bowkota on Fri 15th Feb 2013 17:12 in reply to "RE: Code Review"
bowkota Member since:
2011-10-12

I have a love/hate relationship with articles like these.

On the one hand it's great to promote readable code, but sometimes I think people get too hung up on what they deem as perfect syntax and can sometimes miss the point of those clever optimisations.

It's a bit like grammar Nazi's who love to correct peoples comments but rarely read deep enough into those posts digest the content being explained.

So I guess what I'm trying to say is that it's good to be reminded about preferred programming practices, just as long as we don't forget the other criteria (usability, performance (if applicable), deadlines)


Well said but you have to remember that your first point about readable code has a direct relationship with usability and performance, which you mention at the end. I'm not a programmer but as a scientist I use other people's code for my work and the readability of their code has a great effect on the usability and performance of my work.
This might apply more often to science than game development but I still think it's a relevant point.

Similarly, a well structured post with good grammar and punctuation makes it much more coherent and thus easier to convey your thoughts.

Reply Parent Score: 3

RE[2]: Code Review
by phoenix on Fri 15th Feb 2013 17:40 in reply to "RE: Code Review"
phoenix Member since:
2005-07-11

It's a bit like grammar Nazi's who love to correct peoples comments but rarely read deep enough into those posts digest the content being explained.


Since you brought it up, it should be "Nazis" and "people's" and you missed a "to" in "those posts digest". ;)

Reply Parent Score: 6

RE[2]: Code Review
by bassbeast on Sat 16th Feb 2013 00:52 in reply to "RE: Code Review"
bassbeast Member since:
2007-11-11

To me the measure of whether code is "good" or "bad" is really VERY simple: Does it do the job as intended? Does it waste resources or use them well? is it stable?

And I would have to say no matter how "pretty" the code is Ken Silverman's Build engine, which not only powered Duke but 2 of my fav games of all time, Redneck rampage (who couldn't love a game where you shoot a titty gun and fling dynamite while drinking beer and eating moonpies while listening to Mojo Nixon?) and BLOOD, which riffs all the cheesy horror tropes of the 80s (you even start in the Phantasm funeral home) while giving in both insanely huge levels with tons of secrets

I'm sure everybody has seen that diagram showing the diff between today's shooters and the games then, how then it was huge expanses filled with secrets while today you are led by the nose from one set piece to the next in a straight line? Well anybody who likes the former should BUY NOW Redneck, duke 3D and Blood, they can be had from GOG quite cheaply and just for joining you can get something like 6 games for free just as a thank you for trying them out which includes warsow and Ultima 4.

These games are still a blast, I still fire up all 3 and have a blast, and since its GOG and DOSBox you can run it on Linux and Mac and anyplace else DOSBox will run so go and get 'em and have a ball!

Reply Parent Score: 2

RE[2]: Code Review
by ebasconp on Sun 17th Feb 2013 01:16 in reply to "RE: Code Review"
ebasconp Member since:
2006-05-09

When looking at code of running software, it is generally "ugly"; but at difference of the beautiful code, it showed it works and scales.

We always forget the fact that we are reviewing code that has been several times modified by several people in order to add new functionality, fix some issues, work in other scenarios or improve the performance.

Reply Parent Score: 2

RE[2]: Code Review
by azrael29a on Mon 18th Feb 2013 18:47 in reply to "RE: Code Review"
azrael29a Member since:
2008-02-26

It's a bit like grammar Nazi's who love to correct peoples comments but rarely read deep enough into those posts digest the content being explained.

"Grammar Nazis"! (no apostrophe needed here)


Regards,
Grammar Nazi ;)
(you didn't see this coming, did you?)

Reply Parent Score: 2

RE[2]: Code Review
by f0dder on Mon 18th Feb 2013 22:27 in reply to "RE: Code Review"
f0dder Member since:
2009-08-05

grammar Nazi's

*twitch*. You did that one purpose, didn't you?

Reply Parent Score: 2

RE: Code Review
by Bill Shooter of Bul on Fri 15th Feb 2013 14:50 in reply to "Code Review"
Bill Shooter of Bul Member since:
2006-07-14

Eh,I've always preferred using arrays rather than numerically named vars. It usually is easier that way.

Reply Parent Score: 2

RE[2]: Code Review
by Alfman on Fri 15th Feb 2013 15:04 in reply to "RE: Code Review"
Alfman Member since:
2011-01-28

Bill Shooter of Bul,

"Eh,I've always preferred using arrays rather than numerically named vars. It usually is easier that way."

I don't prefer arrays, but I guess I can see why you would.


My concern would that in many languages the arrays will have an additional performance cost though, requiring more indirection and more calls to alloc/free, and maybe more bounds checking as well. Even with C, the array might conceivably force the compiler to use a specific memory structure when the variable solution might have allowed more register optimizations. Its very hard to predict compiler's optimization behavior these days though.


Edit: How would you formulate a draw line function using arrays?
drawline(single x1, single y1, single x2, single y2);
drawline(single x[2], single y[2]);

// Above is too weird for me, structures would be a bit better.
drawline(coord p1, coord p2)
drawline(coord p[2]);

Edited 2013-02-15 15:11 UTC

Reply Parent Score: 2