Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Yanick (3196)

Yanick
  (email not shown publicly)
http://babyl.dyndns.org/techblog

Journal of Yanick (3196)

Saturday July 19, 2008
08:31 PM

Object::InsideOut Cheatsheet

[ #36961 ]

Everybody is raving about Moose these days, but I must say that I still prefer Object::InsideOut. One of the things I love about OIO is its extensive documentation (70 glorious pages worth of pod!). One of things that I find daunting about it is, well, finding back the attribute I'm looking for as I thumb through those seventy-something blasted pages.

So I made myself a cheatsheet. It's not complete yet, but it's already containing what most mortals would use on a daily basis.

(btw, I've used Scribus to generate the 3-fold. Although I really, really want to like that software, I must say that it makes me miss Quark XPress real bad. If anyone has any suggestion for an alternative Desktop Publishing tool, please feel free to let me know.)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Just curious, why do you prefer OIO over Moose?

    • As I said, it's merely a preference. There's nothing that I found so far that is a show-stopper or an overwhelming advantage for any of them. This being said...

      The biggest plus of OIO, for me, is how inside-out objects ensure that colliding fields are not clobbered, but masked:

      package Foo;
      use Moose;
      has 'x' => ( default => 'foo', is => 'rw' );

      package Bar;
      use Moose;
      extends 'Foo';
      has 'x' => ( +default => 'bar' );

      package main;
      my $obj = Bar->new;
      say $obj->x;       

  • The first impression from the synopsis is that the syntax seems pretty comfortable.

    And from what I could tell by browsing the docs it does deal with my biggest problem with inside-out-objects: debuggability.

    With the dynamic typing in Perl, if I'm confused as to what I'm looking at it's essential to be able to dump the object data structure easily just to see what's what. I'm assuming (well, hoping) that's covered by the "Object Serialization" blurb.

    • It is covered. And provided that your class is relatively plain vanilla, the dump() method will do what you want:

      package Foo;
      use Object::InsideOut;
      my @x : Field :Acc('x') :Default('foo');
      my @y : Field :Acc('y') :Default('bar');
      my @z : Field :Acc('z') :Default('baz');

      package main;
      my $obj = Foo->new;

      use Data::Dumper;
      say Dumper $obj->dump;