Flyweight Pattern Code Review
Define the Flyweight Factory Object
Code Review
- Flyweight Pattern - Part 1: Define the Pattern Interface and Handler Objects
- Flyweight Pattern - Part 2: Define the Flyweight Factory Object
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]); } } }
public FlyweightFactory() { flyweights.Clear(); } public IFlyweight this[String index] { get { if (!flyweights.ContainsKey(index)) { flyweights[index] = new Flyweight(); } return (flyweights[index]); } } }
Printer Friendly Version
Add to Favourites
DotNet Kicks
Digg
del.icio.us
Live Favourites
ma.gnolia
reddit
Slashdot
Technorati
Yahoo!