| Most of us are familiar with the term 'flyweight objects' in Perl OO speak, which refers to objects where the blessed thingy is a scalar that is the index into something (a hash or array) containing the object's attributes.
I happened to re-read the Flyweight pattern a few nights ago, and that description doesn't quite do the pattern justice. People often assume that "flyweight" means "small", since the point of the pattern is to separate intrinsic from extrinsic state such that objects that carry only intrinsic state (i.e., flyweights) can be shared multiple times. A common optimization is to have the flyweight hold an index into an attribute table, but important distinction is that attributes can't refer to state outside of the object itself if that reference would render the flyweight unsharable. Any non-shareable needs to be passed in by the client. A good test for whether you're really doing Flyweight right is to consider whether you can implement individual flyweight objects as singletons.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||