Slash Boxes
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Inside-out objects are really neat and cool. That's why I don't think I will use them.

    There are definite benefits, like improved encapsulation, but I don't need a shotgun -- especially one that has lots of overhead costs. In Perl, avoiding tight coupling can be reduced to a cultural problem, in my experience.

    Sometimes, I use a pattern like this:

        $object->{__PACKAGE__}{attr} = $value;

    Now the object's guts are well divided into areas of authority. If you, Subclass::Happy start screwing aro
    • That solves only one of the two problems Inside-Out Objects try to solve.

      The other is turning (possibly hard to find) runtime errors into compile time errors.

      Preferring $hash -> {attr} (or $hash -> {__PACKAGE__} {attr}) over $attr {refaddr $ref} is, IMO, as sane as preferring package variable and 'no strict' over lexical variables and 'use strict'.

      Inside-Out Objects has never been about providing encapsulation with a shotgun. It simply favours perl5-style variables ('strict', 'lexical') over perl4-style variables ('no strict', 'package'). An attribute, after all, is simply a variable.

      • Yes, that's a very good point, and what I suggested doesn't address it at all. I wonder whether a bit of sugar around restricted hashes could provide something 80% as useful without many of the drawbacks of inside-out objects... but I haven't given it much thought, let alone experimentation.