A random retweet pointed me at this article in Kotaku praising the beauty of Doom 3 source code. It’s especially interesting to me, because Id Software’s coding guidelines are remarkably similar to my own style. Minimal comments, vertical spacing, public fields where it makes sense, minimal operator overloading… it’s all there. One place where I disagree with these guidelines is in the use of
printf over I/O streams. Folks,
printf is unsafe! It’s one thing to avoid excessive templates, and another entirely to make your code deliberately less robust out of some religious hate for the STL (which, by the way, most programmers simply aren’t qualified to replace). Conversely, I side with the Id guidelines against the article’s author in regard to method names. Wanna know why it’s a bad idea to name your methods
getLength() instead of
length()? Because it’s like writing “
make X the get the length of Y” versus “
make X the length of Y“. The latter makes sense in English. The former just doesn’t.
Don’t be a slave to code conventions. Always think things through. And make sure to read source code written by others from time to time.