Monks,
I've been trawling through a few of our modules in work to find where a value is set. After a bit of head scratching I found the following:
## Accessors
sub fields_hash { $_[0]->{_fields_hash}; }
sub fields { $_[0]->{_fields}; }
and then elsewhere...
push @{$self->fields()}, $field;
$self->fields_hash->{$field->fullname()} = $field;
that is, the (so called) accessors are also being used as the (only) means to fill in the values.
Is it just me, or is this bad? For a start, it took me more time than it might have to find the relevant bit of code.. Conway says accessors should be used to write-protect values, and that seems reasonable to me. Any opinions?
Jasper
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.