I'm not entirely sure where you learned object orientation, but it seems you need a new lesson in it. Object Orientation is a methodology a way of writing a program. Which means that its principles are language agnostic. Perl in my opinion is one of the worst languages to write oop programs in because it breeds hideous techniques such as yours. Attribute encapsulation is a cornerstone of OOP. The simple fact of the matter, is that accessors/mutators are methods to retrieve bits of object data or set bits of object data. What they do and how they do it is irrelevant. From my point of view, there are very few times when you would want to expose member variables (a.k.a attributes) to the public. Indeed, I've never encountered a situation which required this. I find the maintainability of encapsulation a Godsend. This allows me to trivially change the data structure without concern. You spoke of tied scalars etc, but by that argument you invalidated your previous argument over performance. You will never convince me that using a tied scalar is more efficient, easier to use, and easier to maintain than accessor/mutators. I'm sure you are a fine procedural programmer, but I would recommend you study up on your OOP before you go giving advice. May I suggest Object Oriented Perl.

On a further note, there are times when pedantry is needed, this was not one of them. When misused pedantry is counter-productive and infuriating. It's like the force, use it well.


In reply to Re: Re^5: OO Getters/Setters by linux454
in thread OO Getters/Setters 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!
  • 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, details, 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, summary, 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.