PHP / ** Builder Mode ** Separates a complex object to its representation, so that the same build process can create different representations. * In order to construct complex objects, the process of constructing complex objects and its components are well decoupled, very Similar abstract factory model ** @Author doodoo
/ *** Builder, explanation How to assemble * @Author doodoo
/ *** How to assemble? Specific objects * / class ConcreteBuilder implements Builder {public function __construct () {// do something} public function buildPartA () {// do something ...} public function buildPartB () {// do something ...} public function BuildPartc () {// do something ...} public function getProduct () {// Return to the results}}
/ *** Machinery ** is responsible for the completion of assembly, assembler know how to assemble ** @author doodoo
/ *** Complex object * / interface product {}
// Test $ Builder = New Concretebuilder (); $ DIRECTOR = New Director ($ Builder);
// The object is assembled. $ DIRECTOR-> Construct (); $ product = $ builder-> getProduct ();
?>