Programming patterns are the tools in a programmer’s tool box. The more usable tools a programmer has the better work he or she can do. Don’t be the man with the hammer, where every problem looks like a nail. Programming patterns are mental models a programmer can draw from when architecting solutions to problems. Game Programming Patterns by Robert Nystrom tackles the practical problem of organizing, structuring and architecting a game’s code base. It’s not always the most glamours or sexy problem to work on, but glue and organization is where a programmer will spend much of the work day. It’s often the hardest part, especially as codebases grow with many contributors. Robert has a very pragmatic approach. Being a perfectionist in the real world is often not very productive. The book reviews some of the patterns from the classic book “Design Patterns: Elements of Reusable Object-Oriented Software” by the Gang of Four as well as many other game programming patterns. Game Programming Patterns is written in a very fun style with lots of game related examples. Some of the patterns covered are very basic game programming concepts like “Double Buffer”, “Game Loop” and “Update Method”. Others are much more advanced. Bellow are some of my take aways from the book.
Don’t overuse Singleton.
Use Abstract Class, Interfaces and Layers of Indirection when there is an actual use case. Don’t use them in a speculative way, just in case they are needed in the future.
Don’t optimize prematurely.
Prototype and Discover with throw away code, just be sure to through it away.
The Command pattern is great for implementing undo/redo.
Be careful with scripting languages. (I’ve been on more than one project where large efforts had to be made to undo scripting languages gone wild in a game).
Deep, complex inheritance hierarchies are out of fashion.
Pattern’s Covered by the Book: