Flyweight Pattern Code Review

Define the Flyweight Factory Object

Code Review

Code Walkthrough

The FlyweightFactory class manages a collection of IFlyweight objects.

class FlyweightFactory { Dictionary<String, IFlyweight> flyweights = new Dictionary<string, IFlyweight>();
public FlyweightFactory() { flyweights.Clear(); } public IFlyweight this[String index] { get { if (!flyweights.ContainsKey(index)) { flyweights[index] = new Flyweight(); } return (flyweights[index]); } } }