What this book covers
Chapter 1, Understanding Object-Oriented Design, explains the philosophy behind writing programs from an object-oriented perspective.
Chapter 2, Learning the Four Fundamental Pillars, discusses the tools object-oriented programming provides to write object-oriented code.
Chapter 3, Creating SOLID Design Solutions, guides you through five core principles of writing good, reusable, and scalable object-oriented code.
Chapter 4, Favoring Composition Over Inheritance, explains that inheritance is a powerful but dangerous tool in object-oriented programming, so we must use it responsibly. In this chapter, you will explore the issues behind inheritance and the composition alternative to achieve code reusability.
Chapter 5, Maintaining Global States with the Singleton Pattern, begins implementing the Singleton pattern for a common issue in game development: global data that multiple objects should have access to.
Chapter 6, Decoupling Objects with the Observer Pattern, discusses coupling, which is a major issue in programming, but it’s unavoidable. But with the Observer pattern, we can make objects communicate without coupling them by using a notification system.
Chapter 7, Spawning Game Objects with the Factory Pattern, covers creating new objects in the game world, which is a skill every game developer needs to master. Using the Factory Pattern can help you do that in a reliable and reusable fashion.
Chapter 8, Changing Object Behavior with the State Pattern, discusses handling object states, which can lead to a chaotic monolith code base that handles state machines and multiple states in a single class. The State pattern is a way to extract this code from the context class with the double benefit of encapsulating each state as an independent object.
Chapter 9, Designing Actors with the Command Pattern, explains that a method, or function, doesn’t leave footprints when called, and this can be an issue. By turning requests into objects, we can store them in memory, store their parameters, pass them around, delay their execution, queue them, execute them in a specific order, and even undo them, and all that is possible using the Command pattern.
Chapter 10, Implementing AI with the Strategy Pattern, explains that using conditional statements to alter the behavior of your code based on specific parameters may not be scalable. The Strategy pattern proposes that, instead, we use objects called strategies that perform different behaviors and adapt the context in real time by passing these objects.
Chapter 11, Creating a Power-Up System with the Decorator Pattern, explores wrapping objects within objects, which is a common practice in programming. The Decorator pattern proposes that we can wrap objects within objects of the same type, allowing us to add new functionalities to them in real time. With this in mind, we create an interesting power-up system for our project, wrapping objects with power-ups.
Chapter 12, Cross-Fading Transitions with the Service Locator Pattern, discusses one way to protect our code from coupling, which is by using a mediator object as an interface to interact with other parts of the game. The Service Locator pattern allows us to perform procedures, such as changing the game music, without leaking implementation and maintenance details on user classes.
Chapter 13, Improving Game Feel with the Event Queue Pattern, explores situations when we need to store events such as keystrokes to be handled in the future. An example is checking whether the player has jumped while in mid-air in the last few milliseconds so that the character performs a jump when they land on the ground. We can achieve this kind of functionality with the Event Queue Pattern.