Implementation Factory

For the full description, implementation variations, consequences, and detailed sample, see Page 229 in Java Application Architecture.


Use factories to create a modules implementation classes.


One of the challenges we face with Abstract Modules is how the object relationships are established at runtime. A class dependent on an abstraction should avoid referencing any of the implementing classes, otherwise anytime a new implementation class is defined, the class dependent on the abstraction also needs to be changed.

If a class depending on an abstraction must be changed when creating a new implementation of the abstraction, the design is flawed.