Abstract Factory Pattern Code Review

Define the Client Object

Code Review

Code Walkthrough

The Client class is responsible for invoking the required methods against a particular product factory.

class Client { private IAbstractBag bag; private IAbstractShoes shoes; private IAbstractBelts belts;
public Client(IAbstractFactory factory) { bag = factory.CreateBag(); shoes = factory.CreateShoes(); belts = factory.CreateBelts(); }
public void ClientMain() { Console.WriteLine(String.Format("I bought a bag which is made from {0}.", bag.Material)); Console.WriteLine(String.Format("I bought some shoes which cost {0}.", shoes.Price.ToString())); Console.WriteLine(String.Format("I bought a belt made from {0} and cost {1}.", belts.Material, belts.Price.ToString())); } }