Es compatible con la adición de nuevos tipos de productos y su familiesExample: interfaz pública IComputerFactory {Ucip createCPU (); IMemory createMemory ();} public interface Ucip {GetCPUString string ();} public interface IMemory {GetMemoryString string ();} //hormigón CPUA clase CPUApublic: Ucip {GetCPUString cadena pública () {return "CPUA"; }} //Clase MemoryApublic hormigón MemoryA: IMemory {GetMemoryString cadena pública () {return "MemoryA"; }} public class ComputerFactoryA: IComputerFactory {createCPU Ucip pública () {return nueva CPUA (); } Public IMemory createMemory () {return nueva MemoryA (); }} class Cliente público {//este es un método de plantilla; no depende de la fábrica de hormigón //y la cadena estática clases de hormigón pública BuildComputer (fábrica IComputerFactory) {cpu Ucip = factory.
createCPU (); Memoria IMemory = factory.createMemory (); StringBuilder sb = new StringBuilder (); sb.Append (string.Format ("CPU: {0}", cpu.GetCPUString ())); sb.Append (Environment.NewLine); sb.Append (string.Format ("Memoria: {0}", memory.GetMemoryString ())); volver sb.ToString ();}} Llamando Clientprivate anular Button2_Click (object sender, EventArgs e) {fábrica Abstract_Factory.IComputerFactory = new Abstract_Factory.ComputerFactoryA();MessageBox.Show(Abstract_Factory.Client.BuildComputer(factory));}