Skip to main content
GameDev.net gamedev.net
🔒 Locked

Unmaintainable code

Started by NightCreature83 Oct 19, 2013 at 7:45 PM 58 replies 35.4k views
TheChubu
TheChubu

I hope they're doing much much better with Overgrowth :D

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"   My journals: dustArtemis ECS framework and 
Pufixas
Pufixas

if(i<numplayers&&i!=k&&player[k].skeleton.free==0&&player[i].skeleton.oldfree==0&&(player[i].targetanimation==jumpupanim||player[k].targetanimation==jumpupanim)&&(player[i].aitype==playercontrolled||player[k].aitype==playercontrolled)&&((player[i].aitype==attacktypecutoff&&player[i].stunned<=0)||(player[k].aitype==attacktypecutoff&&player[k].stunned<=0))){
    if(findDistancefast(&player[i].coords,&player[k].coords)<10*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)&&findDistancefastflat(&player[i].coords,&player[k].coords)<2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
        if(player[i].targetanimation==jumpupanim&&player[k].targetanimation!=getupfrombackanim&&player[k].targetanimation!=getupfromfrontanim&&animation[player[k].targetanimation].height==middleheight&&normaldotproduct(player[i].velocity,player[k].coords-player[i].coords)<0&&((player[k].aitype==playercontrolled&&player[k].attackkeydown)||player[k].aitype!=playercontrolled)){

lolwut?

“There are thousands and thousands of people out there leading lives of quiet, screaming desperation, where they work long, hard hours at jobs they hate to enable them to buy things they don't need to impress people they don't like.”? Nigel Marsh
nevS
nevS

It's the god method pattern! laugh.png

21st Century Moose
21st Century Moose

10,000 lines.

A loathing for whitespace.

Globals all over the place.

Only god I'm seeing here is Cthulhu.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
slicer4ever
slicer4ever

nuke it....it's the only way to be sure.

edit: this is so bad, i have to edit this post, because i feel that quote does not do justice to how terrible this code is, and i'm so scared that it would somehow survive a nuke just for the shear fact of how bad it is. I actually feel a bit woozy looking at it.

samoth
samoth

This is... wow. If that actually compiles without errors, and the resulting binary actually works, then I bow in awe.

Cornstalks
Cornstalks

My response was this: What is he talking about? It's just a blank file. I see nothing. Granted, it's thousands of lines of nothing, but I can maintain blank lines pretty well.

**scroll around, notice I can scroll to the right, and so I scroll to the right as much as I can**

Oh.. Oh no... No no no no no. That can't be... Yup... it really is... HOLY !@#!

Ohforf sake
Ohforf sake
Read a bit into it and it seems, that all the game logic, all the little scripts that you usually attach to triggers, everything of every level, even dialogs, was compiled into the Game::Tick function, including the trigger checks for them (if (distanceToThing < ...) { ...} ).


If there was a yearly contest for the Coding Horrors forum, that 6854 LOC method would be a close contender. If at all, only seconded by that OBJ rendering code s.b. posted.
21st Century Moose
21st Century Moose

I've just done something incredibly stupid.

I looked at more of the code. OK, I was thinking along the lines of "it can't all be that bad, maybe this one is some kind of freak and the rest of it is normal".

It is all that bad. I need to go lie down in a dark room now.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
Veiled Glitch
Veiled Glitch

I really hope overgrowth is doing better, because that code beyond terrible. If in If in If in If IF IF IF! wacko.png

For the first few seconds I was still looking for it, and thinking that it was a blank page, nope.

nuke it....it's the only way to be sure.

Nuking it won't be enough I'm afraid, NUKE IT TWICE DAMMIT!

swiftcoder
swiftcoder

On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
Datamancer
Datamancer

Holy hell, that list of extern variables...

"The code you write when you learn a new language is shit.
You either already know that and you are wise, or you don’t realize it for many years and you are an idiot. Either way, your learning code is ob
TheChubu
TheChubu

On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?

It certainly says a lot about the drive of Wolfire to finish their game.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"   My journals: dustArtemis ECS framework and 
samoth
samoth

On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?

If that's the actual code the produced the title that shipped (and not some kind of joke), then like I said, I bow in awe. I find that code horrible, but as bad as the code may look... writing such a thing is one story, debugging and making it work it is yet another.

If the author really managed to turn this into a working product (and if it was successful, it must have been kind of functional), that was truly some great work. Now imagine what he could do otherwise...

TheChubu
TheChubu

On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?

If that's the actual code the produced the title that shipped (and not some kind of joke), then like I said, I bow in awe. I find that code horrible, but as bad as the code may look... writing such a thing is one story, debugging and making it work it is yet another.

If the author really managed to turn this into a working product (and if it was successful, it must have been kind of functional), that was truly some great work. Now imagine what he could do otherwise...

The authors are these guys http://www.wolfire.com/

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"   My journals: dustArtemis ECS framework and 
21st Century Moose
21st Century Moose

On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?

On that score even worse, I'd say, as it might give out the idea that this is the way to write successful titles. Sure, you can't argue with the success, but the ends don't justify the means.

I note from their blog post announcing it's release: "The coding style is what you might expect from a self-taught high school student, so it could be a challenge to understand" so at least the author(s) acknowledge it's dreadfulness (if in a somewhat understated way), and I've also found that some poor fool has (or had) a fork of the code with the intention of cleaning it up. That's ... brave.

There's probably a moral to this story, something about not letting the endless quest for perfect code get in the way of actually getting stuff done, but this really does lie at one extreme whereas the ideal place to be would be somewhere in the middle.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
swiftcoder
swiftcoder




There's probably a moral to this story, something about not letting the endless quest for perfect code get in the way of actually getting stuff done, but this really does lie at one extreme whereas the ideal place to be would be somewhere in the middle.

QFT.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
Hodgman
Hodgman




I note from their blog post announcing it's release: "The coding style is what you might expect from a self-taught high school student, so it could be a challenge to understand" so at least the author(s) acknowledge it's dreadfulness (if in a somewhat understated way),
Until I read that, I assumed that the code was produced by an automated tool, stitching together snippets laugh.png .... sad.png

On the bright side, their compilation times would be pretty fast!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.