On the beauty of source code
by Felix on Jan.18, 2013, under Opinion
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.
January 24th, 2013 on 15:25
I never liked the get/sets
they’re mostly overused… i dont like properties either.
Sometimes are cool, sometimes is good when you need to let the user know that calling/modifying a property will have secondary effects (like high cpu usage, or db access).
but then, good coding practice of cacheing results will be ok.
Either way, in videogames… dunno,
i’ve seen people try to implement the MVC patter in a videogame, and made me cry.