creativity is that spark of electricity before an explosion.
it allows us, in a single instance to explore all possibilities without hesitation.
|
// Factory Method pattern -- Structural example
|
|
using using System.Collections; namespace DoFactory.GangOfFour.Factory.Structural { // MainApp test application class MainApp { static void Main() { // An array of creators Creator[] creators = new Creator[2]; creators[0] = new ConcreteCreatorA(); creators[1] = new ConcreteCreatorB(); // Iterate over creators and create products foreach(Creator creator in creators) { Product product = creator.FactoryMethod(); Console.WriteLine("Created {0}", product.GetType().Name); } // Wait for user Console.Read(); } } // "Product" abstract class Product { } // "ConcreteProductA" class ConcreteProductA : Product { } // "ConcreteProductB" class ConcreteProductB : Product { } // "Creator" abstract class Creator { public abstract Product FactoryMethod(); } // "ConcreteCreator" class ConcreteCreatorA : Creator { public override Product FactoryMethod() { return new ConcreteProductA(); } } // "ConcreteCreator" class ConcreteCreatorB : Creator { public override Product FactoryMethod() { return new ConcreteProductB(); } } } Output expected:
Created ConcreteProductA
andCreated ConcreteProductB |
| [+] | Programming - WCF |
| [+] | Programming - Design patterns in Software |
| [+] | Programming - Mediator Behavioral Design Pattern |
| [+] | Embedded Systems Engineering Embedded software and embedded systems, are those that require 100% o.. |
| [+] | Enterprise Java performance tuning tips |
| [+] | Microsoft Announces New Support for Silverlight by Content Companies Worldwide |
| [+] | Forward thinking eCommerce is the next-generation dot com Forward thinking eCommerce is about pr.. |
| [+] | Java (J2EE) provides a scalable and robust framework for Enterprise application development Java .. |
| [+] | Embedded Systems Engineering Embedded software and embedded systems, are those that require 100% o.. |
| [+] | .NET Enterprise provides a truly robust and scalable platform to build business applications on I.. |
| [+] | The Future of Javascript - The Creator ponders |
| [+] | Java and .NET both bring something to the Enterprise arena |
| [+] | Object Oriented Programming |
| [+] | Programming - Flyweight Structural Design Pattern |
| [+] | Programming - Template Behavioral Design Pattern |
