Summary
In this last chapter, we have covered three patterns that will boost the efficiency of your game, if implemented correctly. In game development, optimization should not be something you consider until it becomes a problem. It is far more important that you get something working first. Data locality should probably be considered as a first measure as it requires the least refactoring of code. Likewise, an object pool is something we would always recommend you have in your project, via a plugin, on standby for when you start to spawn a lot of the same object. The dirty flag pattern is much more situational, though, and is only applicable when an object has lots of edits versus few read actions per second. Armed with these tools, you should be able to make a dent in the frame rate, destroying the spaghetti mess that all projects become before release. There are always more ways to optimize code beyond this too – some not quite so obvious – but the key is to remember...