Welcome to the Monastery | |
PerlMonks |
Re^8: Flyweights - different meaning in perl?by adrianh (Chancellor) |
on Dec 16, 2002 at 18:33 UTC ( [id://220294]=note: print w/replies, xml ) | Need Help?? |
Absolutely last comment :-) Actually I think it is very clear that the motivation is reducing the number of objects. I suppose data hiding might be a benefit but in general I don't respect data-hiding efforts in perl as valid activities. The idea is that instead of having one hash per object you now have a few larger structures per class but each object is only required to be a scalar. TheDamian's method implements a particular representation of objects in perl data structures. The number of objects (be they hashes or blessed scalars) stays the same. The amount of state (be it in a per-object hash or in a class-local array) stays the same. The flyweight pattern (in the DP world) is about making decisions about what state is stored where, and choosing a set of classes and objects that reduces the total number of objects in existence. It's a design decision (that's why they're called design patterns). You're right that TheDamian's method can be a more memory efficient way of implementing objects - but it doesn't affect the design of the object hierarchy. It's an implementation choice. Abigail-II's inside-out objects also save memory, but it doesn't make them a flyweight pattern. I'll shut up now :-)
In Section
Meditations
|
|