Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Perl Monk, Perl Meditation
 
PerlMonks  

Re^8: Flyweights - different meaning in perl?

by adrianh (Chancellor)
on Dec 16, 2002 at 18:33 UTC ( #220294=note: print w/ replies, xml ) Need Help??


in reply to Re^7: Flyweights - different meaning in perl?
in thread Yet Another Perl Object Model (Inside Out Objects)

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 :-)


Comment on Re^8: Flyweights - different meaning in perl?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://220294]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2014-04-20 21:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (487 votes), past polls