Wednesday, October 28, 2015

Builder

The Builder pattern separates the construction of an complex object from its representation.
This way, the same construction method can have multiple output formats.


The Reader lets the construction of the output format to a converter (which is the builder here). Finally, the client will recover the output from the builder.

Check list

  1. Decide if a common input and many possible representations (or outputs) is the problem at hand.
  2. Encapsulate the parsing of the common input in a Reader class.
  3. Design a standard protocol for creating all possible output representations. Capture the steps of this protocol in a Builder interface.
  4. Define a Builder derived class for each target representation.
  5. The client creates a Reader object and a Builder object, and registers the latter with the former.
  6. The client asks the Reader to "construct".
  7. The client asks the Builder to return the result.

0 comments:

Post a Comment