Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Thanx for your reply to my wondering :), Porculus!

> What are you thinking of here? ... You have an opaque reference.

Right: The opaque reference is what this situation practically results in. And right, it's code reuse/code inheritance with method overriding and attribute access that's the sore point. And again correct, one should be quite certain that non-blackbox-use is what one actually wants to do. But this is one valid way of the ways of TIMTOWTDI in Perl.

And considering that code reuse through inheritance is a dodgy thing in the first place, the dodginess factor goes through the roof when you don't even control the code you're reusing!

There's indeed a line of thinking to limit inheritance to interfaces at most, and especially not code. But I think the field's larger than that, also allowing for e.g. a kind of 'friend'/greybox-inheritance relationship, provided friends are cautious enough and do not trample all over each other's "name space".

There's also the question of the interface offered by an object, including the kind of get/set methods it permits. Maybe even direct access. Wouldn't it be nice to just use Data::Dumper and that were enough to have the object itself tell us its set/get methods? Some kind of default assumptions of 'usually you do it that way' would be nice. Then one'd just need to check the doc's pitfalls section listing possible non-default caveats and exceptions. Less things to remember is a good thing TM.

It's probably mostly a question of trust, assumptions, convenience and code reduction when subclassing.

If you just use objects, then it's at most the get/set attribute issue. When composing objects w/o inheritance, its also pretty harmless. For real code inheritance with method overriding I think the idea I liked best was to stuff the extra data in a closure. But when you subclass and override a method, you'll normally want to minimize the code replication. And this definitely gets more than ugly/dodgy or rather fat, when you need to treat everything as opaque black boxes.

> more about Perl being conceptually messy, than about that messiness causing real problems in practice

With one exception (<> in one-liners), I actually like the messiness and TIMTOWTDI (incl. freedom of choice for possible OO-styles) and wouldn't wish to reduce it.

Just specifying a primus-inter-pares among the OO-ways already in Perl5 would have been nice: kind of "and this is the default set of oo-memes for Perl, divergences from it are documented" (substitute "Pattern" or "Pattern-Language" if you wish); but w/o disabling any of the alternatives, please.

This is IMHO one point where just the lower age of Python & Ruby (and thus their different/bolder/newer approach to OO) is enough to turn into a major sellingpoint for this pair of youngsters.


In reply to Re^5: Questions from "Coders at Work" by jakobi
in thread Questions from "Coders at Work" by bsb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (7)
    As of 2014-07-25 10:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (170 votes), past polls