Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Yet Another Perl Object Model (Inside Out Objects)

by adrianh (Chancellor)
on Dec 15, 2002 at 04:51 UTC ( [id://219964]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Yet Another Perl Object Model (Inside Out Objects)
in thread Yet Another Perl Object Model (Inside Out Objects)

To answer your original question:

A question: Why do you serialise objects?

Three reasons:

  1. Debugging - quick 'n' dirty view of the current objects state.
  2. Persistance
  3. Copying - soemtimes a quick freeze/thaw cycle is the simplest way

As to your other comments, I tend towards having serialisation be the responsibility of the class, since it gives you more flexibility.

This doesn't mean that you have to write a brittle serialisation method for each class - there is nothing stopping you using Storable within your classes freeze/thaw methods (note: "using" not "inheriting from" - inheritence is overrated :-)

This gives you flexibility (you can change your serialisation method on a class by class basis if necessary) and simplicity (common functionality sits in the serialisation class).

The "problem" with inside-out objects is that the "simple" case - dump all of the attributes - becomes hard. You can't just throw $self at Storable::freeze in your classes "freeze" routine.

  • Comment on Re^4: Yet Another Perl Object Model (Inside Out Objects)

Log In?
Username:
Password:

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

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

    No recent polls found