To read all comments associated with this story, please click here.
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
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.
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!
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.
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





Member since:
2011-01-28
"Note : If a file/variable name features a number: it is probably not a good name !"
Anyone heard of Advo Sched? No...oh well.
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