No Time To Play

On the beauty of source code

by 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.

:,

1 Comment for this entry

  • Nande!

    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.

Leave a Reply

*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Posts by month

Posts by date

January 2013
M T W T F S S
« Dec   Feb »
 123456
78910111213
14151617181920
21222324252627
28293031