Writing code

In school I was taught to plan out my code before writing it. They told me code reuse was important, and only high-quality, well-designed code was reusable. Slapdash, ad-hoc programming was a sign of incompetence and laziness.

So I always tried hard to write good code. After graduate school, I worked at Google, where no one was allowed to write any code until a design doc had been written, checked by a committee, revised, and approved. This was important, because Google's code was to be high-quality reusable stuff, and they didn't want anyone wasting time writing code that might have to be rewritten later.

When I left Google and starting building games in small teams, I kept all those old habits, assuming that they'd help my projects. Planning, writing up design docs, carefully building reusable code...these were the marks of a true professional. My code would be a thing of beauty, a testament to my engineering skills and long years of training.

But I discovered that this type of process is not appropriate when building a game in a small team. The problem is that a fun game can't be planned out in advance. It is impossible to design a game on paper, then build it, and have that game be a success. Only by iteration and testing can a game be made fun, and you can't iterate when the design of the code is set in stone at the design doc phase.

These days I write all of my code quickly without planning much at all. The idea is to get something, anything, working, as fast as possible. If the code becomes a problem (slow, unreadable, buggy, inflexible...), I can clean it up or rewrite it later. More likely, the code will be just fine, or get thrown away in a later iteration. So why try for perfect code up front? Why face the paralysis of an empty editor window and pressure to write the BEST CODE EVAR? Just write code. Write it! And fix it up later. Or not.


There is no "right way" to build software. There are no "best practices" for coding. If it looks like a haphazard collection of bolted-on pieces, it's because you moved quickly, iterated fearlessly, and shipped. Awesome!