Java Reference
In-Depth Information
SOLUTION 16.4
Figure B.19 shows that the two credit check classes implement the CreditCheck interface.
The factory class provides a method that returns a CreditCheck object. The client that calls
createCreditCheck() does not know the precise class of the object it receives.
Figure B.19. Two classes implement the CreditCheck interface. The decision of which
class to instantiate lies with the service provider rather than with the client that needs
a credit check.
The createCreditCheck() method is a static method, so clients need not instantiate
the CreditCheckFactory class in order to get a CreditCheck object. You can make
this class abstract or give it a private constructor if you want to actively prevent other
developers from instantiating it.
Search WWH ::




Custom Search