The Factory Method design pattern provides a solution:
Define a separate operation (factory method) for creating an object.
Create an object by calling a factory method.
Describing the Factory Method design in more detail is the theme of the following sections.
See Applicability section for all problems Factory Method can solve.