Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I've always been big on the "shotgun quote" not because of the idea that enforcement in not neccessary, but that writing accessors and mutators ad nauseum is silly

... i.e, by convention a blessed hash with internal data should only be accessed externally by class methods, and if the functions don't exist, it's at-your-own-risk. Internal hash-access, thereby being unacceptable/against-convention/etc ...

Bottom line -- everything is private if you agree to stay out of the living room, and that's a great design point. Once you start saying "I have a shotgun, but you can come in if", you start walking down the road of non-OO-OO, aka java-esque accessor/mutator hell.

I suspect there are a lot of yet undiscovered uses for this technique that will only be revealed with time and community acceptance. If nothing else, it will shutup the Java people claiming that Perl OO has poor encapsulation.

As much as I hate Java, I won't defend a failing in Perl when I see it. Perl does have horrible encapsulation, primiarly because of what you had to write to achieve it. Perhaps if stuff like this was in the core module distribution, a la "use ObjectVoodoo" or somesuch, we could argue the language did it well, but as it stands, the language does it poorly, and it becomes the role of the coder to fix the language ... hence (at least) Java speaks it more fluently. Usually java coders get it all wrong though -- and by no means is java a shining example of OO.


In reply to Re: May Thy Closures Be Blessed by flyingmoose
in thread May Thy Closures Be Blessed by hardburn

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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 all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (7)
    As of 2017-09-21 11:18 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      During the recent solar eclipse, I:









      Results (245 votes). Check out past polls.

      Notices?