Creator Mode Builder
The creator pattern is to separate the construction of a complex object from its representation, so that the same build process can create different representations, while the client does not have to know the object's build details. You can use the Creator mode when the system needs to create a complex set of objects, and this complex object is more cumbersome to assemble.
Extract all the functional classes from the abstract factory pattern into a single class
Factory class is only responsible for the creation of objects, not responsible for the assembly of objects, through the director class to Assemble,
The abstract factory pattern is similar to the creator pattern, but the creator pattern further implements a single function of the class
Creator mode
How the creator pattern is implemented
The creator pattern is actually an abstract factory-mode evolutionary version.
Abstract Factory mode
Public abstract class FactoryMethod () {protected abstract Translate factorymethodtranslate ();p rotected Abstract Interpret Factorymethodinterpret ();p rotected abstract Speech Factormethodspeech ();p ublic string Saytext (string text) { Translate Translate = Factorymethodtranslate (); Interpret interpret = Factorymethodinterpret (); Speech Speech = Factorymethodspeech (), return Translate.saytext () + "--" + interpret.saytext () + "---" +speech.saytext ();}}
Creator mode
Public abstract class FactoryMethod () {protected abstract Translate factorymethodtranslate ();p rotected Abstract Interpret Factorymethodinterpret ();p rotected abstract Speech Factormethodspeech ();}
public class Director () {private FactoryMethod factorymethod;public FactoryMethod Getfactorymethod () {return factory;} public void Setfactorymethod (FactoryMethod factorymethod) {this.factorymethod = FactoryMethod;} public string Saytext (string text) {Translate Translate = factorymethodtranslate (); Interpret interpret = Factorymethodinterpret (); Speech Speech = Factorymethodspeech (), return Translate.saytext () + "----" + interpret.saytext () + "---" +speech.saytext () ;}}
Design mode (v) Creator mode (Builder)-Create type