<?xml version="1.0" encoding="windows-1252"?>
<node id="220027" title="Re^2: Flyweights - different meaning in perl?" created="2002-12-15 12:22:45" updated="2005-08-13 20:09:09">
<type id="11">
note</type>
<author id="186362">
adrianh</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;em&gt;I've studiously avoided the term "flyweight objects" as I have only ever seen it here and didn't really understand its meaning. I'll stick to "Inside-out" which only has meaning in perl terms as far as I am aware.&lt;/em&gt;&lt;/blockquote&gt;

&lt;p&gt;Fair enough, but [id://219525|other] [id://219561|people] [id://219968|have] - which makes me suspect it means something different in the perl and design pattern worlds.&lt;/p&gt;

&lt;p&gt;Which would be annoying. One of the main advantages of the design pattern movement for me is  the development of a common vocabularly (finally, everybody knows what a singleton is :-). If it means something different in the perl world it would be useful to know.&lt;/p&gt;

&lt;blockquote&gt;&lt;em&gt;With regard to the example you describe, that may have made some sense in the world of 8-bit chars as you only need a pool of 256 object, but in the world of UCS, it becomes excessive I think...&lt;/em&gt;&lt;/blockquote&gt;

&lt;p&gt;I don't really want to repeat everything in the chapter from the book, but basically...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The context is a word processor, so "character" doesn't just mean the code, it might support methods like draw(), intersects(), etc. We're talking WYSIWYG layout support.&lt;/li&gt;
&lt;li&gt;I didn't mean to imply you had to create the whole pool of characters at once, you would create them as needed for a document and add them to the pool.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As for practicality, the example was in the book was adapted from the Doc editor, produced using InterViews 3.0. Take a look at:

&lt;ul&gt;
&lt;li&gt;Paul R. Calder and Mark A Linton. Glyphs: Flyweight bjects for user interfaces. In ACM User Interface Software Technologies Conference, pages 92-101, Snowbird, UT, October 1990.&lt;/li&gt;
&lt;li&gt;Paul R. Calder and Mark A Linton. The object-oriented implementation of a document editor. In Object-Oriented Programming Systems, Languages and Applications Conference Proceedings, pages 154-165m Vancouver, British Columbia, Canada, October 1992. ACM Press.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To quote from the [isbn://0-201-63361-2|Design Patterns] chapter on flyweights:&lt;/p&gt;

&lt;blockquote&gt;
Doc uses glyph objects to represent each character in the document. The editor builds one Glyph instance for each character in a particular style (which defines its graphical attributes); hence a character's intrinsic state consists of the character code and its style information (an index into a style table). This means only position is extrinsic making Doc fast.
&lt;/blockquote&gt;

&lt;p&gt;If you're interested in the details I'd recommend picking up a copy of [isbn://0-201-63361-2|Design Patterns] and giving the flyweight chapter a read.&lt;/p&gt;</field>
<field name="root_node">
219924</field>
<field name="parent_node">
220010</field>
</data>
</node>
