Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
adrianh asked me to comment on this thread.

Yes, the "flyweight objects" described in "OO Perl" are structurally capable of being used as Flyweight Objects (in the Gang of Four sense).

No, the example code shown in "OO Perl" doesn't implement the full flyweight metaphor. Specifically, it doesn't include the necessary constructor code to check if an object already exists (in the logical sense) and so avoid reinstantiating it in that case.

In other words, both sides of this debate were essentially correct. Isn't postmodernism wonderful? ;-)

Why did I stop short of explaining the full technique? Well, even though the changes required to the constructor code would have totalled only a few lines, explaining the concept underlying the full pattern would have required several additional pages of exposition, and I was already 200 pages over my contract limit as it was.

Besides, it was (and still is) my assessment that the most significant application of this type of class is in providing robust, yet maintainable, encapsulation. In Perl at least, its other ability -- to optimize away duplicate value-type objects -- is much less commonly needed.

In reply to Re: Flyweights - different meaning in perl? by TheDamian
in thread Yet Another Perl Object Model (Inside Out Objects) by demerphq

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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:
    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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (3)
    As of 2021-01-19 04:23 GMT
    Find Nodes?
      Voting Booth?