Handles are the better pointers
A few years ago I wanted to make a shoot-em-up game using C# and XNA I could play with my kids on an Xbox. It worked fine except for slight pauses for GC every once in a while which ruined the experience.<p>The best solution I found was to get rid of objects and allocation entirely and instead store the state of the game in  per-type tables like in this article.<p>Then I realized that I didn&#x27;t need per-type tables at all, and if I used what amounted to a union of all types I could store all the game state in a single table, excluding graphical data and textures.<p>Next I realized that since most objects had properties like position and velocity, I could update those with a single method by iterating through the table.<p>That led to each &quot;object&quot; being a collection of various properties acted on by independent methods which were things like gravity and collision detection. I could specify that a particular game entity was subject to gravity or not, etc.<p>The resulting performance was fantastic and I found I could have many thousands of on-screen objects at the time with no hiccups. The design also made it really easy to save and replay game state; just save or serialize the single state table and input for each frame.<p>The final optimization would have been to write a language that would define game entities in terms of the game components they were subject to and automatically generate the single class that was union of all possible types and would be a &quot;row&quot; in the table. I didn&#x27;t get around to that because it just wasn&#x27;t necessary for the simple game I made.<p>I was inspired to do this from various articles about &quot;component based game design&quot; published at the time that were variations on this technique, and the common thread was that a hierarchical OO structure ended up adding a lot of unneeded complexity for games that hindered flexibility as requirements changed or different behaviors for in-game entities were added.<p>Edit: This is a good article on the approach. <a href="http:&#x2F;&#x2F;cowboyprogramming.com&#x2F;2007&#x2F;01&#x2F;05&#x2F;evolve-your-heirachy&#x2F;" rel="nofollow">http:&#x2F;&#x2F;cowboyprogramming.com&#x2F;2007&#x2F;01&#x2F;05&#x2F;evolve-your-heirachy...</a>