The factory method pattern

The factory method pattern is designed to solve the following design problems:

The factory method pattern lets you decouple the call site from the instantiation site in your code. This makes it easier to refactor, update, or change the instantiation of the target object without compromising the consuming part of your code.

The factory method will be responsible for instantiating objects, instead of the call site. It usually comes in multiple flavours: