Sponsored By

The "Good Performance, Well Written Code" Trap

Imagine you're developing the structure for your tile-based game map. How hard is that? Very hard, actually. It only depends on you.

Guilherme Paz, Blogger

November 6, 2016

4 Min Read

Originally published here.

If you're a seasoned game developer you might not be interested in this article, as it approaches a trap that prevents me from being productive and, well, be a seasoned developer myself.

The Problem

I work with software development for 8 years and, for the last couple of days, I've been designing and writing another game project. As you can imagine, it barely has a structure; and that's a very complex issue for me for the simple matter of 'must write perfect code'. I noticed, though, that this 'mind directive' of mine has been a productivity killer and you might have that too without noticing. Let's see.

The Anecdote

Imagine you're developing the structure for your tile-based game map. How hard is that?

Very hard, actually. It only depends on you.
"But how, if it's only a tiled map bare bones?", you ask me. Well, let's start a healthy conversation about two developers:

"I want to start allocating the map and rendering it to screen!"
"Width, Height and an array of ids, with each id being the identifier for a thing with a sprite. God, that's so easy."

"Well, my map will be pretty big, I can't just render everything..."
"Okay, let's create some sections to divide the map, and you'll render only what's in your screen. The map will contain the sections, each section can contain the ids for it's area."

"Ahn... I kinda need layers too, so I can have objects above my terrain!"
"Damn. Alright, here's the deal: each section will have an array of layers. You'll encapsulate your tile ids in the layers and the sections will be only a pivot for what do render. Right?"

"Alright, that seems nice! But, about the pathfinding..."

At that point, the other developer has already walked away, prepared his coffee and you got the gist.


First, I want to point out three things:

  1. Yes, the annoying developer is me (the tutor one is my evil alter ego);

  2. Those are real concerns I actually tried to solve (and succeeded, with a lot of frustration and time spent too early);

  3. The solutions were the ones I implemented, and were not thought by me, but by Tynan Sylvester of RimWorld. You can check his video about his map structure here

The Epiphany

With that out of the way, I want to talk a bit about my struggle with good written code. Again, if you're a seasoned game developer you might not be interested in this; if that's not the case, you may wanna try to dodge this bullet consciously.

I say 'consciously' because for the last year I'm at home treating leukemia (I'm fine, thanks) and, as you've guessed, I've been developing (or trying to develop) some games. A whole year and no, I haven't finished anything, mainly because I didn't realize that I kept focusing on:

  • how I could refactor everything to work neater...

  • ... if this method should be here or there for better encapsulation...

  • ... shit this is not using polymorphism right...

  • ... the quality of my code regarding naming, commenting, if I should use field or property...

  • ... yada yada yada, many other creativity-suicidal thoughts

That rollercoaster of being too demanding of myself in the start of every project has, every time, stolen my passion for the design I had.

Don't get me wrong: writing readable, coherent, encapsulated, using-polymorfism-and-interfaces-and-extensions-right code is, within reason, important. But, honestly, not to get a prototype running, and sadly that is the farther me and a lot of other devs (I presume) have got because of this precocious perfectionism.

The Tip

My (yet to follow appropriately) tip is "just do it"; not in the motivational sense, but in the "worry about results first and performance later" sense. Seeing that you're getting somewhere, even with a troubling performance at first, will get you pumped enough to carry on.

Maybe I could've thought of this before as many other people already have, but the truth is most of people will only apply this "simple" moto once they start to realize how much effort they're putting into something that should be a lot simpler and functional, and that's what I'm trying to communicate here because it's what happened to me.

I wrote all this not because I know how to get things up and running, but because I didn't actually get there yet, and I finally understood why. I've been more productive from the couple of days I realized that until now than in the rest of my year writing good, OOP-compliant code that won't ever be released.

I hope you could find some utility in my epiphany.

Keep coding (and stop worrying too much).

Read more about:

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

You May Also Like