|Syntactic Confectionery Delight|
Re: Re^4: Flyweights - different meaning in perl?by BrowserUk (Pope)
|on Dec 16, 2002 at 01:19 UTC||Need Help??|
Update: Having found and read this description of Flyweight objects, I noticed first that the equipment being used was a DECstation 3100 (a machine I well remember playing "moonlander" on 16 or more years ago. It was "state-of-the art then and wowed everyone that saw it) and then noticed that the dates on the paper and the references therein were 1987,1988 & 1989. I then realised that this description of flyweight objects comes from a time when it may well have been considered unusual and new, though I don't recall them having a great impact at the time.
Prior to this I was under the impression that "flyweight objects" were being hailed as something new and different, and was intrigued to learned more, but was confused by what I read. Effectively the referenced paper puts that idea to bed and makes the rest of this post redundant.
I'll leave it here as is the apparent preference of the community as testimony that just because you haven't encountered the name of something, that you haven't been unwittingly using it for years. I guess what goes around comes around:^)
Getting by the fact that I was arguing against the example given rather than the definition itself.
Can you explain to me how an object can have extrinsic state?
Using the Glyph example. The text given said that Doc was fast because it used Glyphs, which had no extrinsic state. The example give for what they did not have was position. If you add the position at which a Glyph is displayed or formatted to the Glyph itself, then you do indeed need many more instances than you would without it.
However, if you add the position information to the Glyph class it then becomes intrinsic? But what you now have is no longer a Glyph class, but a Glyph_At_This_Position class. To my way of thinking that just doesn't make sense.
You have a list (small-l) of Positions at which to display Glyphs, and you give the Glyph to the Position not vice-versa. That way, when you reformat to a different page width, you run down the list of Posistions and adjust them and the Glyphs move appropriately. If that means I'm wanting to use Flyweight objects for my Glyphs, then so be it, but it seems like a strange name for the concept and hardly new.
I mean, we build strings from chars, we don't tell a char that it occupies position 7 in this string?
Examine what is said, not who speaks.