Factory Method Pattern
You don’t know what kind of object you will need until runtime.
Use the Factory Method pattern and choose the object to be generated dynamically.
Say that you need to load a file into an editor but you don’t know its format until the user chooses the file. A class using the Factory Method pattern can serve up different parsers depending on the file’s extension.
In the example, you can ignore the specifics of the file’s format and focus on the parsed content. A more advanced Factory Method might, for instance, also search for versioning data within the file itself before returning a more precise parser (e.g. an HTML5 parser instead of an HTML v4 parser).