Book Image

Learning Design Patterns with Unity

By : Harrison Ferrone
Book Image

Learning Design Patterns with Unity

By: Harrison Ferrone

Overview of this book

Struggling to write maintainable and clean code for your Unity games? Look no further! Learning Design Patterns with Unity empowers you to harness the fullest potential of popular design patterns while building exciting Unity projects. Through hands-on game development, you'll master creational patterns like Prototype to efficiently spawn enemies and delve into behavioral patterns like Observer to create reactive game mechanics. As you progress, you'll also identify the negative impacts of bad architectural decisions and understand how to overcome them with simple but effective practices. By the end of this Unity 2023 book, the way you develop Unity games will change. You'll emerge not just as a more skilled Unity developer, but as a well-rounded software engineer equipped with industry-leading design patterns.
Table of Contents (23 chapters)
21
Other Books You May Enjoy
22
Index

Flyweight or Type Object?

Both the Flyweight and Type Object patterns deal with performance and optimization in similar ways, and they’re often taught all mashed together, which makes it difficult to understand the intent behind each one and the different solutions they offer.

With the Type Object pattern, the intent is to create new complex classes without using big inheritance hierarchies. This pattern is also about data rather than behavior (as Type Objects don’t typically act on extrinsic state), but you’ll see a fair bit of memory optimization as a side bonus. You also don’t see factories come into play with the Type Object because they are structured to privately create and return new instances of themselves, so there’s no additional need for this abstraction layer (which isn’t to say you can’t add it). Again, this is where the line gets murky between these two patterns, as they can be combined and still function, but the...