http://qs321.pair.com?node_id=221042


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

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.

Replies are listed 'Best First'.
Re: Re: Flyweights - different meaning in perl?
by demerphq (Chancellor) on Jan 05, 2003 at 23:06 UTC
    would have required several additional pages of exposition, and I was already 200 pages over my contract limit as it was.

    /me patiently waits for the directors cut to be released...

    ;-)

    --- demerphq
    my friends call me, usually because I'm late....

Re^2: Flyweights - different meaning in perl?
by adrianh (Chancellor) on Dec 19, 2002 at 08:57 UTC

    Thanks for the comments

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

    <group hug>

    :-)