Flyweight Sample Implementation
✓ Published0🌍 Public
Aandresmijares
Last edited Nov 2, 2016
Created on Nov 2, 2016
This example demonstrates the Flyweight design pattern by sharing common task properties across many task objects. The `Task` constructor stores only the unique `name` property directly, while delegating shared attributes like `project`, `priority`, `user`, and `completed` to a `Flyweight` object managed by a `FlyweightFactory`. The factory caches flyweights using a concatenated key of these shared values and exposes a `getCount` method to track the number of distinct flyweights created. The code relies on plain JavaScript object literals and factory closures, with no external visualization libraries.
AI-generated description