Breaking down the Object Pool pattern
While the Object Pool pattern wasn’t included in the original Gang of Four content, we’re still counting it as part of the Creational family of design patterns because, well, its area of expertise is literally object creation. Because the Object Pool pattern is about pooling shared objects rather than creating and destroying objects one at a time, you’ll find it most useful when:
- You have objects that are instantiated and destroyed at a high rate and/or are computationally expensive to instantiate (think about how many bullets a first-person shooter has to put onscreen when you’re really in the thick of it).
- You want to keep track of and control memory allocation when creating objects.
- You want to improve performance by allocating and reusing objects with a predictable memory footprint and timeframe.
If you’ve been to a library, you’re intimately familiar with how Object...