Item 30. Factory Method
A high-level design often requires the creation of an object of the “appropriate” type, based on the type of an existing object. For example, we may have a pointer or reference to an
Employee object of some kind, and we need to generate the appropriate kind of
HRInfo object for that type of
Employee, as shown in Figure 8.
Figure 8. Pseudoparallel hierarchies. How should we map an employee to its corresponding human resources information?
Here we have almost parallel
Hourly employees require the generation of an
StdInfo object whereas a
Temp requires a
The high-level ...