Posts

Showing posts from January 2, 2012

Design Patterns -- Abstract Factory Pattern

Image
Abstract Factory Pattern is a type of Creational Pattern . What is Abstract Factory Pattern? Let’s go by Definition in Gang of Four (GOF) “ Provide an interface for creating families of related or dependent objects without specifying their concrete classes “ Let’s look into this pattern for an example where we are products which can be categorized for Basic, Regular, Seasonal etc. We will create an interface for the abstract product as show below     interface IProductFactory     {         Hashtable ProductProperties();     } The next step we will create a concrete product class     class BasicProduct : IProductFactory     {         public Hashtable ProductProperties()         {             Hashtable ht = new Hashtable ();             ht[ "Type" ] = "FMCG" ;             ht[ "Name" ] = "Soap" ;             return ht;         }     }     class SeasonalProduct : IProductFactory