Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Heh ... thanks! Really what was bothering me was a statement I've read over and over in texts that deal with Object-Oriented programming (but not about using it in any particular language) which was:
A subclass shouldn't need to know anything about its parent's implementation, and the parent shouldn't need to know anything about a child's implementation

Or something along those lines. And while I was experimenting by trying to create a very generic "person" object (which could then become person::client, person::employee, person::vendor etc) I realized that I would end up violating both of those ideas by storing data inside a hash-ref as object

If I had been working on this for a paid project I would have just plowed forward as I'd be the one writting the subclasses anyway ...

However, since this was a learning experience, I was annoyed by the idea of 'cheating' and figured there had to be a way. I had once seen (here on perlmonks) using braces around a subroutine { $var; sub { ... }} to keep a variable alive between calls to the subroutine and used that in figuring out what I did.

I think after I read/learn Abigails implementation -- which I have no doubts is much more refined then my Saturday afternoon of hacking around -- I would likely use this as my default OO style.

theAcolyte


In reply to Re^2: Why is a hash the default "object" in oo perl? by theAcolyte
in thread Why is a hash the default "object" in oo perl? by theAcolyte

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 pondering the Monastery: (5)
    As of 2014-04-18 01:42 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (460 votes), past polls