It is still examples in Java and mode, (Java and Mode Yan Hong) The following is the code that is converted to delphi, this time I added a comment :)
Unit builderpattern;
Interface
TYPE TPRODUCT = Class;
// Abstract constructor specification interface
TBuilder = class (TObject) public procedure builderpart1 (); virtual; abstract; procedure builderpart2 (); virtual; abstract; function returnProduct (): TProduct; virtual; abstract; end;
// The specific category class, the component is created with him so that the client doesn't have to know the specific construction details
TConcreteBuilder = class (TBuilder) private product: TProduct; public procedure builderpart1 (); override; procedure builderpart2 (); override; function returnProduct (): TProduct; override; end;
// Product class
TPRODUCT = Class (TOBJECT) / / END;
// Director role directly by the client
TDIRECTOR = Class (TOBJECT) Private Builder: TBUilder; Public Procedure Initialize (); End; Implementation
{TDIRECTOR}
Procedure tdirector.initialize; begin builder: = tconcretebuilder.create; builder.builderpart1 (); builder.builderpart2 (); builder.returnproduct;
{Tconcretebuilder}
Procedure tconcretebuilder.builderpart1; begin // your code;
Procedure tconcretebuilder.builderpart2; begin // your code;
Function TCONCRETEBUILDER.RETURNPRODUCT: TPRODUCT;
End.