Sponsored By

What Was I thinking? The Existential Cognitive Dissonance Of Updating Old Code

Updating old code, especially code I have not touched in nearly a decade is like a ride in a time machine. A really crappy time machine that only highlights my mistakes makes me feel like an idiot.

Steve Fulton, Blogger

November 3, 2012

3 Min Read
Game Developer logo in a gray background | Game Developer



I spent the last week updating an old game engine so that it could run on iOS.   Back in 2005, when I first built that particular game engine, I spent months crafting the code.   I recall the pride I felt when I look at my program listings back then.  They were filled with objects, events, reused functions, a particle manager I wrote from scratch, a sound manager, a level-ramping structure that was easy to update and expand, and many other pieces of fancy code that I was sure to reuse in the coming years.   Over the course of the project I felt I had become a coding artiste.  I was an adept at crafting algorithms that made the game sing.  I could weave magic and the game were producers like putty in my hands.  To me at least, it felt like objects and functions dripped off my fingers, forming sonnets of execution that that would have made other programmer weep, if I would only allow them to see my amazing, secretive code.  

Curiously, after the game was finished, I moved on.  My next project was completely different, and I started again, mostly from scratch.  While I barrowed some of the ideas from the code, I never reused that old engine again. While the experience inspired things I did later one, I never went back to that engine for anything major.  It sat on my hard drive gathering pixel-dust, becoming legendary in my own mind. Until last week when, like I said before, I dusted off the old game engine so I could update it for iOS.

When I looked at the code with my 2012 eyes I surprised to find one common denominator among all the masterful code I had developed seven years ago: 

It was CRAP!   

I mean awful, terrible crap.   My "state of the art" coding in from 2005 appeared so hacky, so make-shift, so inept, I could not believe it was the same "piece of art" I was so sure I had crafted years ago.  It was not "magic" at all.  It was almost-competent for the time I suppose, but nothing special.   In fact, I found something I could optimize in nearly every function and class.

I had run smack into my existential problem of cognitive dissonance when updating old code.    It's cognitive dissonance because when updating old code, I have two conflicting views swimming in my head: the code once formed a successful game, so it must be a good starting point, right?  However while trying to update it, that very code drives me nuts because it does not meet my modern engineering expectations.  At the same time, it's an existential problem.   Why? Because feels like a microcosm of life.  It's just like the mental exercise of "If I knew then what I know now", but amplified because I only have myself to blame.  It shatters an internal view of myself and my work that I might have held for a long time.   Updating old code, especially code I have not touched in nearly a decade is like a ride in a time machine.  A really crappy time machine that only highlights my mistakes makes me feel like an idiot.

And that's a good thing.

As a programmer, I get better every time I sit down and write code.  I learn more from mistakes than from successes, and I build upon both to get better and better at my craft.   The truth is that old code was probably pretty good for the time was written.  It solved a particular problem, it served me well, and it helped me continue to grow as a developer.  The fact that I now think it is "crap" only proves that practice helps me grow, and as a developer, I will never stop learning.  

Read more about:

Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like