Jasper has asked for the wisdom of the Perl Monks concerning the following question:
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:
and then elsewhere...## Accessors sub fields_hash { $_[0]->{_fields_hash}; } sub fields { $_[0]->{_fields}; }
that is, the (so called) accessors are also being used as the (only) means to fill in the values.push @{$self->fields()}, $field; $self->fields_hash->{$field->fullname()} = $field;
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: accessor abuse..?
by djantzen (Priest) on Aug 22, 2002 at 13:39 UTC | |
by tantarbobus (Hermit) on Aug 22, 2002 at 15:06 UTC | |
by djantzen (Priest) on Aug 22, 2002 at 15:45 UTC | |
by tantarbobus (Hermit) on Aug 22, 2002 at 17:17 UTC | |
by Aristotle (Chancellor) on Aug 22, 2002 at 23:23 UTC | |
|
Re: accessor abuse..?
by sauoq (Abbot) on Aug 22, 2002 at 15:15 UTC | |
|
Re: accessor abuse..?
by lachoy (Parson) on Aug 22, 2002 at 16:56 UTC |