Summary
In this chapter, we focused on the communication between reusable engine code and game specific gameplay code. We learned that it can be difficult to make a clear distinction between these two parts because the gameplay code has the potential to creep into every system. This makes sense because to make a game, you must write code that interacts with every other system. However, this means reusing code is a little difficult.
We saw that the solution to this was to decouple our engine and gameplay code by having all communication go through interface classes. These interface classes were the basis for what is known as the Observer pattern. By using this pattern, we can make our code much cleaner and easier to use, and reuse.
The Observer pattern is as easy as it gets when it comes to design patterns. Few patterns are as simple to implement or understand. Once you start using it you will wonder how you ever programmed without it. However, we also learned there are some things to watch...