Ray's playground

 

Builder

Definition

Separates the construction of a complex object from its representation so that the same construction process can create different representations.

Class Diagram

Participants

  • Builder.
    • specifies an abstract interface for creating parts of a Product object
  • ConcreteBuilder.
    • constructs and assembles parts of the product by implementing the Builder interface
    • defines and keeps track of the representation it creates
    • provides an interface for retrieving the product
  • Director.
    • constructs an object using the Builder interface
  • Product.
    • represents the complex object under construction. ConcreteBuilder builds the product's internal representation and defines the process by which it's assembled
    • includes classes that define the constituent parts, including interfaces for assembling the parts into the final result

Example:

Vehicle

 

VehicleBuilder

 

MotorcycleBuilder

 

CarBuilder

 

Shop

 

Program

posted on 2009-02-21 15:08  Ray Z  阅读(338)  评论(0)    收藏  举报

导航