12 ABSTRACT FACTORY

This pattern was previously described in GoF95.

DESCRIPTION

During the discussion of the Factory Method pattern we saw that:

  • In the context of a factory method, there exists a class hierarchy composed of a set of subclasses with a common parent class.
  • A factory method is used when a client object knows when to create an instance of the parent class type, but does not know (or should not know) exactly which class from among the set of subclasses (and possibly the parent class) should be instantiated. Besides the class selection criteria, a factory method also hides any special mechanism required to instantiate the selected class.

The Abstract Factory pattern takes the same concept to the next level. In simple terms, an ...

Get Software Architecture Design Patterns in Java 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.