Het ondersteunt het toevoegen van nieuwe soorten producten en hun familiesExample: openbare interface IComputerFactory {ICPU createCPU (); IMemory createMemory ();} openbare interface ICPU {snaar GetCPUString ();} openbare interface IMemory {snaar GetMemoryString ();} //Concrete CPUApublic klasse CPUA: ICPU {public string GetCPUString () {return "CPUA"; }} //Concrete MemoryApublic klasse MemoryA: IMemory {public string GetMemoryString () {return "MemoryA"; }} public class ComputerFactoryA: IComputerFactory {public ICPU createCPU () {return nieuwe CPUA (); } Public IMemory createMemory () {return nieuwe MemoryA (); }} public class Client {//Dit is een sjabloon-methode; is niet afhankelijk van de betonfabriek //en Concrete klassen public static snaar BuildComputer (IComputerFactory fabriek) {ICPU cpu = factory.
createCPU (); IMemory geheugen = factory.createMemory (); StringBuilder sb = new StringBuilder (); sb.Append (String.Format ("CPU: {0}", cpu.GetCPUString ())); sb.Append (Environment.NewLine); sb.Append (String.Format ("Memory: {0}", memory.GetMemoryString ())); terug sb.ToString ();}} Bellen Clientprivate vervallen Button2_Click (object afzender, EventArgs e) {Abstract_Factory.IComputerFactory fabriek = new Abstract_Factory.ComputerFactoryA();MessageBox.Show(Abstract_Factory.Client.BuildComputer(factory));}