I rarely rant about other programmers’ code; partly because I know for one I am not a stellar programmer, and for two, I couldn’t write code on computer graphics or advance algorithms like path-finding, so I know my place within the tier of the arcane arts of programming and don’t comment much on others’ code.
What I am good at (or maybe just skilled at) is infrastructure; the organisation of code. I like neat code; I think I know what neat code looks like, so I am always in the job of making other people’s code modular and generic.
Enough of the introduction. So right now I am looking at a piece of code that could petrify Medusa, make Cyclops wince, bring down the wrath of Zeus and sour the love of Athena. I don’t even know where to begin. I just keep going “ARRGH” every 5 minutes when I look at the spaghetti code that is on my plate (how do you manage to get that type of code in C++!?)
A sprite consists of an animation; an animation consists of many frames. I layered this way for my sanity, and passed it to the level 99 CG programmer to do his magic. He’s way better than me; I ought to treat him with respect, but I almost got a panic attack when I saw his code. Make it whenever I saw his code
(Disclaimer: His code works, in a sense that you get pretty results on the screen).
So I have to refactor it such that is generic. And here are my woes…
-
In changing the position of an entity, he changed the position of the animation, not the sprite. I forgot which rule of object oriented programming he broke, but all I know is that this is broken.
-
When drawing the content of a frame, he offset each vertice in glVertice3f instead of using a translate. Cough blood It just broke something, I don’t know what it is exactly now.
-
The sudden inclusion of several dozen public variables into all the classes…
-
and he just directly bypass encapsulation to access them!! In the main update loop, he would access a public property of a frame and change it so that the visuals would work…
-
Variable names that quicken my pulse. pivotX vs. pviotOrgX and no comments to indicate what is the difference.
He had taken a modular structure and make it so tightly coupled that I am at loss - either I refactor the entire monster by hacking at it for a week or I write replacement classes so that I can do some smaller unit tests, which would amount to a week anyway. Face palm
On the good side, if I manage to untangle his code and get it to work, I would learn some valuable CG programming techniques…
ETA: I think my internal circuit are fried too. May a moderator please invoke his almighty administrator power and move it to MPSIMS? I’m sorry, I am really sorry. But bad code really broke my concentration on all other things too.