The Design patterns book gives the following applicability for the Flyweight design pattern (bold emphasis mine):
Applicabilty
The Flyweight pattern’s effectiveness depends heavily on how and where it’s used. Apply the Flyweight pattern when all of the following are true:
- An application uses a large number of objects.
- Storage costs are high because of the sheer quantity of objects.
- Most object state can be made extrinsic.
- Many groups of objects may be replaced by relatively few shared objects once extrinsic state is removed.
- The application doesn’t depend on object identity. Since flyweight objects may be shared, identity tests will return true for conceptually distinct objects.
Instead of storage costs (space resources), would instantiation costs (time resources) make for a valid application as well?
Aucun commentaire:
Enregistrer un commentaire