Builder Pattern Code Review
Define the Pattern Interface and Handler Objects
Code Download
- Download Description:builder pattern download
- .NET Framework:3.5
- ..NET Language:C#
- Date Published:2009-07-01
- Download Size:9 KB
Code Review
- Builder Pattern Code Review: Define the Pattern Interface and Handler Objects
- Builder Pattern Code Review: Define the Factory Director and Factory Product Objects
- Builder Pattern Code Review: Use the Builder Pattern
Code Walkthrough
Define the IProductBuilder interface to be used as the "blueprint" for the main Builder classes.
void BuildFrame(); void BuildEngine(); void BuildWheels(); void BuildDoors(); }
This interface defines the methods required to construct a specific object.
The MotorCycleBuilder class (object) represents a Builder class.
public FactoryProduct Product { get; private set; }
public void BuildFrame() { this.Product["frame"] = "MotorCycle Frame"; } public void BuildEngine() { this.Product["engine"] = "500 cc"; } public void BuildWheels() { this.Product["wheels"] = "2"; } public void BuildDoors() { this.Product["doors"] = "0"; } }
This class inherits from the IProductBuilder interface, and therefore implements the required methods to construct a MotorCycle object.
The VehicleBuilder class (object) represents a Builder class.
public FactoryProduct Product { get; private set; }
public void BuildFrame() { this.Product["frame"] = "Vehicle Frame"; } public void BuildEngine() { this.Product["engine"] = "2500 cc"; } public void BuildWheels() { this.Product["wheels"] = "4"; } public void BuildDoors() { this.Product["doors"] = "4"; } }
This class inherits from the IProductBuilder interface, and therefore implements the required methods to construct a Vehicle object.
The ScooterBuilder class (object) represents a Builder class.
public FactoryProduct Product { get; private set; }
public void BuildFrame() { this.Product["frame"] = "Scooter Frame"; } public void BuildEngine() { this.Product["engine"] = "50 cc"; } public void BuildWheels() { this.Product["wheels"] = "2"; } public void BuildDoors() { this.Product["doors"] = "0"; } }
This class inherits from the IProductBuilder interface, and therefore implements the required methods to construct a Scooter object.
Printer Friendly Version
Add to Favourites
DotNet Kicks
Digg
del.icio.us
Live Favourites
ma.gnolia
reddit
Slashdot
Technorati
Yahoo!