Implementation Factory

by kirk knoernschild

Statement

Use factories to create a modules implementation classes.

Description

One of the challenges we face with abstract coupling is creation of the implementation class. A client class cannot create an implementation class if we want the two classes abstractly coupled. Figure 1 illustrates the Implementation Factory pattern.

ImplementationFactory

Figure 1: Implementation Factory Pattern

Implementation Variations

Implementation Factory is often used with Abstract Module and Separate Abstractions.

Where does the factory live.

What is the factory? Class or framework such as Spring.

Injection or Lookup.

Consequences

Sample Code

LoanSampleImplementationFactory

Figure 1: Implementation Factory using Spring

In abstract modules, we were left wondering how to create the implementation class without referencing the concrete class within the client.jar module.

Wrapping Up