Factory Method Pattern Code Review
Define the Factory Object
Code Download
- Download Description:factory method pattern download
- .NET Framework:3.5
- .NET Language:C#
- Date Published:2009-07-01
- Download Size:8 KB
Code Review
- Factory Method Pattern Code Review: Define the Factory Object
- Factory Method Pattern Code Review: Define the Product Interface and Handler Objects
- Factory Method Pattern Code Review: Use the Factory Method Pattern
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();
}
}
}
Printer Friendly Version
Add to Favourites
DotNet Kicks
Digg
del.icio.us
Live Favourites
ma.gnolia
reddit
Slashdot
Technorati
Yahoo!