Chapter 17. Abstract Factory

Sometimes, you want to provide for object creation while retaining control of which class to instantiate. In such circumstances, you can apply the FACTORY METHOD pattern with a method that uses an outside factor to determine which class to instantiate. The outside factor can be anything. In Chapter 16, Factory Method, this factor was the status of an online credit agency. Sometimes, the factor that controls which object to instantiate can be thematic, running across several classes. The ABSTRACT FACTORY pattern addresses this situation. The intent of this pattern is to provide for the creation of a family of related, or dependent, objects.

Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.