Flyweight

An object shared between many clients for efficiency/resource purposes rather than having an individual instance for each client. Each client contains specific (extrinsic) information about the object while properties that are the same (intrinsic) are stored within the flyweight.

Use when:

Example C++ Code

 // The flyweight class
class Glyph 
{
public:
    virtual ~Glyph();

    virtual void Draw(Window*, GlyphContext&);
protected:
    Glyph();
};

// the concrete flyweight (a character instance, such as 'a', 'b', ...)
class Character : public Glyph
{
public:
    Character(char);

    virtual void Draw(Window*, GlyphContext&);
private:
    char _charcode;
};