4 January 2011

Sins of Game Programming #2 – Code Obfuscation - by Michael Carr

      Posted 01/01/11 09:54:00 pm  

One of my flaws for those that don’t know me is that I simply don’t remember everything. My brain it would appear is completely incapable of storing all the facts and information I ask it to. Over the years I have used different methods to help me remember, all with varying degrees of success.  My current system is to write everything down, I carry a black leather writing notebook with me and I take lots of notes. I use a P.D.A. for some things like contacts and mind maps but when it comes to making lists and notes, paper and pen have yet to be beaten.

One of the effects of this forgetfulness is that I couldn’t tell you the intimate details of a function I had written two weeks ago, let alone six months or a year ago without at least re-reading it and refreshing my memory. It is because of this that I consider obfuscated code a sin. This also fits nicely with working in a team of programmers where someone might have to debug and/or add new functionality to someone else’s code. The quicker it is to understand the easier it is for them to make the required modifications.


Descriptive names

Badly named variables and functions don’t help anyone. These examples I found in code that had shipped.

    int            m_MyMumIsBetterThanYours;

No it wasn’t a game about Mum’s… although I wander if there is a game there somewhere… hmmm... 

    bool           m_BumCheeks;

Enough said.

    float          m_Saving;

Is this a flag to indicate saving, in which case why a float? Or is it a percentage of save completed?


No comments:

Post a Comment