Factory Method Pattern Code Review

Define the Factory Object

Code Download

Code Review

Code Walkthrough

The Factory class (object) defines the FactoryMethod() method, which decides which subclass to instantiated.

class Factory { public Product.IProduct FactoryMethod(Int32 month) { if (month >= 4 && month <=11) { return new Product.ProductA(); } else if (month == 1 || month == 2 || month == 12) { return new Product.ProductB(); } else { return new Product.ProductC(); } } }