Java Reference
In-Depth Information
Now suppose that a requirements analyst tells you that Oozinoz wants to start servicing
customers in Canada. To do business in Canada, you will use a different credit agency and
different data sources to establish attributes of customer addresses, such as whether they incur
tariffs or are residential. When a customer calls, the call center application needs a
family
of
objects to perform a variety of checks. The family to use depends on whether the call is from
Canada or from the United States. You can apply the A
BSTRACT
F
ACTORY
pattern to provide
for the creation of these object families.
Suppose that you decide to maintain three packages. Package
com.ooz-inoz.check
will
contain three
check
interfaces and an abstract factory class. This class will have three
create
methods that create the three kinds of check objects. You will also put
CreditCheckOffline
in this package, as you can use this class for offline checks
regardless of a call's origin. Figure 17.2 shows the new contents of
com.oozinoz.check
.
Figure 17.2. The revised package contains primarily interfaces and an abstract factory
class.
To implement the interfaces in
com.oozinoz.check
with concrete classes, you can
introduce
two
new
packages:
com.oozinoz.check.canada
and