Java Reference
In-Depth Information
CHALLENGE 16.4
Draw a class diagram that establishes a way to create a credit-checking object while
retaining control of which class to instantiate.
By applying F ACTORY M ETHOD , you let the user of your services call
the createCreditCheck() method to get a credit-checking object that works regardless
of whether the credit agency is online.
CHALLENGE 16.5
Assume that the CreditCheckFactory class has an isAgencyUp() method
that tells whether the credit agency is available, and write the code for
createCreditCheck().
Factory Method in Parallel Hierarchies
The F ACTORY M ETHOD pattern often appears when you use parallel hierarchies to model
a problem domain. A parallel hierarchy is a pair of class hierarchies in which each class in
one hierarchy has a corresponding class in the other hierarchy. Parallel hierarchies usually
emerge when you decide to move a subset of behavior out of an existing hierarchy.
Consider the construction of aerial shells, as illustrated in Chapter 5, Composite. To build
these shells, Oozinoz uses the machines modeled in Figure 16.2.
Search WWH ::




Custom Search