Abstract Factory Pattern Code Review

Define the Product Interfaces and Handler Objects

Code Review

Code Walkthrough

Define the IAbstractBag interface to be used as the "blueprint" for the product application classes.

interface IAbstractBag { String Material { get; } } interface IAbstractShoes { Int32 Price { get; } } interface IAbstractBelts { String Material { get; } Int32 Price { get; } }

This interface is used to define the different product classes (objects).

The GucciBag and PoochyBag classes (objects) represent particular product classes.

class GucciBag : IAbstractBag { public String Material { get { return "Crocodile skin"; } } } class PoochyBag : IAbstractBag { public String Material { get { return "Plastic"; } } }

The two classes (objects)are unrelated to each other and represent one type of product against another type of product.

The GucciShoes and PoochyShoes classes (objects) represent particular product classes.

class GucciShoes : IAbstractShoes { public Int32 Price { get { return 1000; } } } class PoochyShoes : IAbstractShoes { public Int32 Price { get { return 1000 / 3; } } }

The two classes (objects) are unrelated to each other and represent one type of product against another type of product.

The GucciBelts and PoochyBelts classes (objects) represent particular product classes.

class GucciBelts : IAbstractBelts { public String Material { get { return "Leather"; } } public Int32 Price { get { return 2000; } } } class PoochyBelts : IAbstractBelts { public String Material { get { return "Plastic"; } } public Int32 Price { get { return 2000 / 3; } } }

The two classes (objects) are unrelated to each other and represent one type of product against another type of product.