ParserBuilder

Decide what to create based on incoming information

Definition

This is a DesignPattern that reads the identifying information from an incoming data stream and creates an object of the appropriate type, removing only one object's worth of data from the stream.  It combines the Interpreter and Builder DesignPatterns.

Source

Parser Builder

Discussion

This allows a LooseInterface to be defined.  The top level Parser builds an object to process the next bit of information, but the identifying token that determines what will be built is not part of the interface definition, this can be agreed later, and the token set can be extended without altering the interface.  This is a variant of the Abstract Factory DesignPattern but the object to be created is defined in the data stream, rather than by the client.