Good day.

I know that it is looked down upon to directly access the variables in an object with any OO programming language, including Perl. Is such still the case when the object in question is fairly complex?

For instance, let's say I have an object "User" whose constructor contains something vaguely like this (this is not a real sample of the code I'm working on, just a bit of mock code):
$self = { fname => "Hot", lname => "Pastrami", properties => { favoriteColors => [ "muave", "periwinkle" ], condiments => [ "mustard", "saurkraut" ], }, };
...would I be expected to write functions to access each of the values in $self->{properties}, or can I get away with assigning directly, such as:
my $user = User->new(); $user->{properties}{favoriteColors}[2] = "sepia";
I know that Perl allows both, but will directly assigning a value in an instance like this cause any self-respecting Perl developer to find me and make my dental records obolete?

Thanks,

Hot Pastrami

In reply to Generally accepted style in Perl objects by Hot Pastrami

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.