Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Design Patterns with Unity

You're reading from  Learning Design Patterns with Unity

Product type Book
Published in May 2024
Publisher Packt
ISBN-13 9781805120285
Pages 676 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Harrison Ferrone Harrison Ferrone
Profile icon Harrison Ferrone
Toc

Table of Contents (23) Chapters close

Preface 1. Priming the System 2. Managing Access with the Singleton Pattern 3. Spawning Enemies with the Prototype Pattern 4. Creating Items with the Factory Method Pattern 5. Building a Crafting System with the Abstract Factory Pattern 6. Assembling Support Characters with the Builder Pattern 7. Managing Performance and Memory with Object Pooling 8. Binding Actions with the Command Pattern 9. Decoupling Systems with the Observer Pattern 10. Controlling Behavior with the State Pattern 11. Adding Features with the Visitor Pattern 12. Swapping Algorithms with the Strategy Pattern 13. Making Monsters with the Type Object Pattern 14. Taking Data Snapshots with the Memento Pattern 15. Dynamic Upgrades with the Decorator Pattern 16. Converting Incompatible Classes with the Adapter Pattern 17. Simplifying Subsystems with the Façade Pattern 18. Generating Terrains with the Flyweight Pattern 19. Global Access with the Service Locator Pattern 20. The Road Ahead 21. Other Books You May Enjoy
22. Index

Common pitfalls

We can get to a well-architected state with less stress if we keep an eye on some common pitfalls. You’ll notice as you read this book that it’s not so much a step-by-step tutorial as it is a reference for when you need to implement a design pattern. Half the skill is learning if, and when, to use one at all.

Let’s summarize:

  • Don’t use a design pattern just for the sake of using it. Impressing a review team or someone on GitHub isn’t worth it. If a part of your game needs some abstraction and decoupling, absolutely do it.
  • Only add complexity where it’s needed. If you find that your project is overly architected, ask yourself if your codebase wouldn’t be cleaner and easier to read without it.
  • Good software architecture is never free. Abstracting code takes time to learn, write, and maintain, and you may take runtime hits to performance and speed.

So why do any of this design pattern nonsense in the first place? Because complexity isn’t a bad word, performance can be improved later on, and the efficiency bump in your development process is well worth the up-front investment. You won’t get it right the first time, so enjoy the iteration. It’s all part of the process. And if you’re like me, using design patterns is like a puzzle, and when that code runs, it’s like finding that last pesky piece your cat hid under the couch – it’s magic.

You have been reading a chapter from
Learning Design Patterns with Unity
Published in: May 2024 Publisher: Packt ISBN-13: 9781805120285
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime