Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Doubt about fly-weight objects.

by blazar (Canon)
on May 17, 2005 at 13:32 UTC ( [id://457795]=note: print w/replies, xml ) Need Help??


in reply to Re: Doubt about fly-weight objects.
in thread Doubt about fly-weight objects.

Indeed I found these links interesting especially in that they show that the concept is not perl-specific as I would have naively thought.

It seems to me that the basic aspect on which most references that were given to me concentrate is that of caching, which supports the actual "light" nature of these objects, as of the name attribution.

However it doesn't seem to me that the typical example one sees about them is really any lighter than "standard" objects. Granted, I see how one could make them so, but that's a different story. Perhaps flyweight objects are really flyweight in other OO {models,languages}.

Note: With the above I mean that the typical perl example of a constructor is:

sub new { my $class = shift; my $id = bless [] => $class; $data{$id} = { foo => undef, bar => undef }; # ... $id; }
or (to speak about Inside-Out):
sub new { my $class = shift; my $id = bless [] => $class; $foo{$id} = undef; $bar{$id} = undef; # ... $id; }
Sometimes one sees \(my $bogus) instead of [], but basically in these typical constructors a unique id is associated to each object, different for all of them.

Side note - OT

While I think that WiKi's such as the referenced one are generally precious resources, I also find their extremely hypertextual nature occasionally confusing and annoying: I tend to have the impression that there may be some relevant node that I missed. Sometimes a slightly more sequential organization would come useful.

Now one -well, I for one- wonders how an ordering could be find (maybe automatically or semiautomatically) in a document that is inherently hypertextual as to make it into a sequential thing...

Replies are listed 'Best First'.
Re^3: Doubt about fly-weight objects.
by dragonchild (Archbishop) on May 17, 2005 at 13:37 UTC
    The conceptual problem you're running into is that Perl's OO model isn't "normal". Every object is a reference, no matter how you slice'n'dice it. This is unlike other languages.

    I've never really had a use for flyweights - either I need a real object or I don't. But, that's just me.


    • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
    • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
      The conceptual problem you're running into is that Perl's OO model isn't "normal". Every object is a reference, no matter how you slice'n'dice it. This is unlike other languages.
      Indeed! What amazes me most of Perl's object model is that not only it integrates nicely with the rest of the language even being more of an afterthought than a design feature (IIUC - bu then I began with 5.6.1), but above all that notwithstanding its semplicity it's possible with relatively moderate efforts to imitate different OO models from other languages...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://457795]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-23 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found