Chapter 5. The Abstract Factory Pattern

The Abstract Factory pattern is one level of abstraction higher than the Factory Method pattern. You can use this pattern to return one of several related classes of objects, each of which can return several different objects on request. In other words, the Abstract Factory is a factory object that returns one of several groups of classes. You might even decide which class to return from that group by using a Simple Factory.

One classic application of the Abstract Factory pattern is when your system needs to support multiple look-and-feel user interfaces, such as Windows 9x, Motif, and Macintosh. You tell the factory that you want your program to look like Windows, and it returns a GUI factory that returns ...

Get Java™ Design Patterns: A Tutorial now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.