June 2003
Intermediate to advanced
800 pages
34h 20m
English
You want the ability to create classes generically, without knowing their specific types.
Create a dedicated factory class that can construct the type of class you need.
The factory pattern is one of the best-known creational patterns. It provides an abstracted mechanism for creating classes.
In the factory pattern, as shown in Figure 4-4, every class has its own corresponding factory class. In order for the factory pattern to work, all of these classes must derive from two abstract base classes.

Figure 4-4. The abstract factory pattern
For example, imagine you want to create a generic component that queries ...
Read now
Unlock full access