Perl Monk, Perl Meditation | |
PerlMonks |
Re: Accessor methods again.by gargle (Chaplain) |
on Oct 04, 2005 at 14:51 UTC ( [id://497270]=note: print w/replies, xml ) | Need Help?? |
Hi, As always, it depends. If you use different accessor methodes for each attribute you can easility mimic public,private, and protected access. See Re: OO - best way to have protected methods for more. If you don't need, don't use (kiss ;)) Different setter methods have an advantage: you can put code in it to check the parameters. As the setting for the attribute in question only occurs in one place your code becomes simpler to update. A single getter/setter shared by all attributes can do the same but becomes complex the moment you have many attributes, plus, you loose the public, private, protected simplicity.
-- if ( 1 ) { $postman->ring() for (1..2); }
In Section
Seekers of Perl Wisdom
|
|