Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: Better Inside-Out Objects :)

by xdg (Monsignor)
on Oct 06, 2006 at 22:06 UTC ( [id://576763]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Better Inside-Out Objects :)
in thread Better Inside-Out Objects :)

the syntax of various inside-out object modules is just frickin' painful to me

So, specifically, the whole "id $self" stuff? I can see that, though I suspect it's all about what people are used to seeing.

I think the overload-like-a-hash approach will be problematic in the long run because the apparent simplicity masks significant complexity.

Serialization is probably the first place this will really pop up and fail to behave like people expect. What happens when someone tries to throw one of these objects at Data::Dumper et al? What happens when someone tries to create an object on the fly by loading data into a hash reference manually and then blessing it into an object? (E.g. loading YAML or other external config data?)

my $ref = { foo => 23, bar => 42, }; bless $ref, "Bar";

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^4: Better Inside-Out Objects :)
by ikegami (Patriarch) on Oct 06, 2006 at 22:36 UTC
    What happens when someone tries to throw one of these objects at Data::Dumper et al?

    That's a problem with Inside-Out Objects in general.

    What happens when someone tries to create an object on the fly by loading data into a hash reference manually and then blessing it into an object?

    They ought to be shot. Constructors (incl cloning and deserializing constructors) exist for a reason. You can't expect to clone an object by copying it's bytes or it's fields.

      That's a problem with Inside-Out Objects

      For Data::Dumper, yes, because its OO approach is broken. Not so for Storable. I was speaking generically.

      You can't expect to clone an object by copying it's bytes or it's fields.

      Ditto for changing its properties by directly accessing its hash, which is why this is a mess.

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

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

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

    No recent polls found